Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.2 KiB

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