home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2004 July / APC0407D2.iso / workshop / apache / files / ActivePerl-5.6.1.638-MSWin32-x86.msi / _37654d7418ef75d3b1e86bbe3746b50f < prev    next >
Encoding:
Text File  |  2004-04-13  |  2.2 KB  |  85 lines

  1. package utf8;
  2.  
  3. if (ord('A') != 193) { # make things more pragmatic for EBCDIC folk
  4.  
  5. $utf8::hint_bits = 0x00800000;
  6.  
  7. sub import {
  8.     $^H |= $utf8::hint_bits;
  9.     $enc{caller()} = $_[1] if $_[1];
  10. }
  11.  
  12. sub unimport {
  13.     $^H &= ~$utf8::hint_bits;
  14. }
  15.  
  16. sub AUTOLOAD {
  17.     require "utf8_heavy.pl";
  18.     goto &$AUTOLOAD if defined &$AUTOLOAD;
  19.     Carp::croak("Undefined subroutine $AUTOLOAD called");
  20. }
  21.  
  22. }
  23.  
  24. 1;
  25. __END__
  26.  
  27. =head1 NAME
  28.  
  29. utf8 - Perl pragma to enable/disable UTF-8 in source code
  30.  
  31. =head1 SYNOPSIS
  32.  
  33.     use utf8;
  34.     no utf8;
  35.  
  36. =head1 DESCRIPTION
  37.  
  38. WARNING: The implementation of Unicode support in Perl is incomplete.
  39. See L<perlunicode> for the exact details.
  40.  
  41. The C<use utf8> pragma tells the Perl parser to allow UTF-8 in the
  42. program text in the current lexical scope.  The C<no utf8> pragma
  43. tells Perl to switch back to treating the source text as literal
  44. bytes in the current lexical scope.
  45.  
  46. This pragma is primarily a compatibility device.  Perl versions
  47. earlier than 5.6 allowed arbitrary bytes in source code, whereas
  48. in future we would like to standardize on the UTF-8 encoding for
  49. source text.  Until UTF-8 becomes the default format for source
  50. text, this pragma should be used to recognize UTF-8 in the source.
  51. When UTF-8 becomes the standard source format, this pragma will
  52. effectively become a no-op.  This pragma already is a no-op on
  53. EBCDIC platforms (where it is alright to code perl in EBCDIC 
  54. rather than UTF-8).
  55.  
  56. Enabling the C<utf8> pragma has the following effects:
  57.  
  58. =over
  59.  
  60. =item *
  61.  
  62. Bytes in the source text that have their high-bit set will be treated
  63. as being part of a literal UTF-8 character.  This includes most literals
  64. such as identifiers, string constants, constant regular expression patterns
  65. and package names.
  66.  
  67. =item *
  68.  
  69. In the absence of inputs marked as UTF-8, regular expressions within the
  70. scope of this pragma will default to using character semantics instead
  71. of byte semantics.
  72.  
  73.     @bytes_or_chars = split //, $data;    # may split to bytes if data
  74.                     # $data isn't UTF-8
  75.     {
  76.     use utf8;            # force char semantics
  77.     @chars = split //, $data;    # splits characters
  78.     }
  79.  
  80. =head1 SEE ALSO
  81.  
  82. L<perlunicode>, L<bytes>
  83.  
  84. =cut
  85.