/usr/share/perl5
NameSizeModeActions
Attribute/-0755rm
B/-0755rm
Class/-0755rm
Compress/-0755rm
Config/-0755rm
CPAN/-0755rm
DBM_Filter/-0755rm
Devel/-0755rm
encoding/-0755rm
ExtUtils/-0755rm
File/-0755rm
Getopt/-0755rm
I18N/-0755rm
IO/-0755rm
IPC/-0755rm
Locale/-0755rm
Math/-0755rm
Memoize/-0755rm
Module/-0755rm
Net/-0755rm
overload/-0755rm
Pod/-0755rm
pod/-0755rm
Search/-0755rm
Term/-0755rm
Text/-0755rm
Thread/-0755rm
Tie/-0755rm
Time/-0755rm
Unicode/-0755rm
unicore/-0755rm
URI/-0755rm
User/-0755rm
vendor_perl/-0755rm
warnings/-0755rm
AnyDBM_File.pm26180644editdlrm
AutoLoader.pm157970644editdlrm
AutoSplit.pm196370644editdlrm
autouse.pm42380644editdlrm
base.pm109800644editdlrm
Benchmark.pm310250644editdlrm
blib.pm20860644editdlrm
bytes.pm37540644editdlrm
bytes_heavy.pl7580644editdlrm
charnames.pm208670644editdlrm
CORE.pod31880644editdlrm
DB.pm189220644editdlrm
DBM_Filter.pm143850644editdlrm
deprecate.pm30790644editdlrm
diagnostics.pm190380644editdlrm
DirHandle.pm15560644editdlrm
Dumpvalue.pm175560644editdlrm
dumpvar.pl155550644editdlrm
English.pm47610644editdlrm
feature.pm170850644editdlrm
fields.pm94890644editdlrm
FileCache.pm55720644editdlrm
FileHandle.pm67840644editdlrm
filetest.pm40030644editdlrm
FindBin.pm45610644editdlrm
if.pm33400644editdlrm
integer.pm32540644editdlrm
Internals.pod25760644editdlrm
less.pm32040644editdlrm
locale.pm48550644editdlrm
Memoize.pm361920644editdlrm
meta_notation.pm21170644editdlrm
NEXT.pm188460644editdlrm
open.pm80210644editdlrm
overload.pm533140644editdlrm
overloading.pm18080644editdlrm
perl5db.pl3164200644editdlrm
PerlIO.pm104590644editdlrm
Safe.pm250820644editdlrm
SelectSaver.pm10760644editdlrm
SelfLoader.pm176920644editdlrm
sigtrap.pm76060644editdlrm
sort.pm60810644editdlrm
strict.pm47380644editdlrm
subs.pm8480644editdlrm
Symbol.pm47990644editdlrm
Test.pm300570644editdlrm
Thread.pm82870644editdlrm
UNIVERSAL.pm65940644editdlrm
URI.pm347900644editdlrm
utf8.pm91160644editdlrm
utf8_heavy.pl316150644editdlrm
vars.pm24140644editdlrm
vmsish.pm43130644editdlrm
warnings.pm447560644editdlrm
XSLoader.pm112670644editdlrm
_charnames.pm331660644editdlrm
Edit: /usr/share/perl5/utf8.pm (9116B)
package utf8; $utf8::hint_bits = 0x00800000; our $VERSION = '1.19'; sub import { $^H |= $utf8::hint_bits; } sub unimport { $^H &= ~$utf8::hint_bits; } sub AUTOLOAD { require "utf8_heavy.pl"; goto &$AUTOLOAD if defined &$AUTOLOAD; require Carp; Carp::croak("Undefined subroutine $AUTOLOAD called"); } 1; __END__ =head1 NAME utf8 - Perl pragma to enable/disable UTF-8 (or UTF-EBCDIC) in source code =head1 SYNOPSIS use utf8; no utf8; # Convert the internal representation of a Perl scalar to/from UTF-8. $num_octets = utf8::upgrade($string); $success = utf8::downgrade($string[, $fail_ok]); # Change each character of a Perl scalar to/from a series of # characters that represent the UTF-8 bytes of each original character. utf8::encode($string); # "\x{100}" becomes "\xc4\x80" utf8::decode($string); # "\xc4\x80" becomes "\x{100}" # Convert a code point from the platform native character set to # Unicode, and vice-versa. $unicode = utf8::native_to_unicode(ord('A')); # returns 65 on both # ASCII and EBCDIC # platforms $native = utf8::unicode_to_native(65); # returns 65 on ASCII # platforms; 193 on # EBCDIC $flag = utf8::is_utf8($string); # since Perl 5.8.1 $flag = utf8::valid($string); =head1 DESCRIPTION The C pragma tells the Perl parser to allow UTF-8 in the program text in the current lexical scope. The C pragma tells Perl to switch back to treating the source text as literal bytes in the current lexical scope. (On EBCDIC platforms, technically it is allowing UTF-EBCDIC, and not UTF-8, but this distinction is academic, so in this document the term UTF-8 is used to mean both). B The utility functions described below are directly usable without C. Because it is not possible to reliably tell UTF-8 from native 8 bit encodings, you need either a Byte Order Mark at the beginning of your source code, or C, to instruct perl. When UTF-8 becomes the standard source format, this pragma will effectively become a no-op. See also the effects of the C<-C> switch and its cousin, the C environment variable, in L. Enabling the C pragma has the following effect: =over 4 =item * Bytes in the source text that are not in the ASCII character set will be treated as being part of a literal UTF-8 sequence. This includes most literals such as identifier names, string constants, and constant regular expression patterns. =back Note that if you have non-ASCII, non-UTF-8 bytes in your script (for example embedded Latin-1 in your string literals), C will be unhappy. If you want to have such bytes under C, you can disable this pragma until the end the block (or file, if at top level) by C. =head2 Utility functions The following functions are defined in the C package by the Perl core. You do not need to say C to use these and in fact you should not say that unless you really want to have UTF-8 source code. =over 4 =item * C<$num_octets = utf8::upgrade($string)> (Since Perl v5.8.0) Converts in-place the internal representation of the string from an octet sequence in the native encoding (Latin-1 or EBCDIC) to UTF-8. The logical character sequence itself is unchanged. If I<$string> is already stored as UTF-8, then this is a no-op. Returns the number of octets necessary to represent the string as UTF-8. Can be used to make sure that the UTF-8 flag is on, so that C<\w> or C work as Unicode on strings containing non-ASCII characters whose code points are below 256. B; use L instead. =item * C<$success = utf8::downgrade($string[, $fail_ok])> (Since Perl v5.8.0) Converts in-place the internal representation of the string from UTF-8 to the equivalent octet sequence in the native encoding (Latin-1 or EBCDIC). The logical character sequence itself is unchanged. If I<$string> is already stored as native 8 bit, then this is a no-op. Can be used to make sure that the UTF-8 flag is off, e.g. when you want to make sure that the substr() or length() function works with the usually faster byte algorithm. Fails if the original UTF-8 sequence cannot be represented in the native 8 bit encoding. On failure dies or, if the value of I<$fail_ok> is true, returns false. Returns true on success. B; use L instead. =item * C (Since Perl v5.8.0) Converts in-place the character sequence to the corresponding octet sequence in UTF-8. That is, every (possibly wide) character gets replaced with a sequence of one or more characters that represent the individual UTF-8 bytes of the character. The UTF8 flag is turned off. Returns nothing. my $a = "\x{100}"; # $a contains one character, with ord 0x100 utf8::encode($a); # $a contains two characters, with ords (on # ASCII platforms) 0xc4 and 0x80. On EBCDIC # 1047, this would instead be 0x8C and 0x41. B; use L instead. =item * C<$success = utf8::decode($string)> (Since Perl v5.8.0) Attempts to convert in-place the octet sequence encoded as UTF-8 to the corresponding character sequence. That is, it replaces each sequence of characters in the string whose ords represent a valid UTF-8 byte sequence, with the corresponding single character. The UTF-8 flag is turned on only if the source string contains multiple-byte UTF-8 characters. If I<$string> is invalid as UTF-8, returns false; otherwise returns true. my $a = "\xc4\x80"; # $a contains two characters, with ords # 0xc4 and 0x80 utf8::decode($a); # On ASCII platforms, $a contains one char, # with ord 0x100. Since these bytes aren't # legal UTF-EBCDIC, on EBCDIC platforms, $a is # unchanged and the function returns FALSE. B; use L instead. =item * C<$unicode = utf8::native_to_unicode($code_point)> (Since Perl v5.8.0) This takes an unsigned integer (which represents the ordinal number of a character (or a code point) on the platform the program is being run on) and returns its Unicode equivalent value. Since ASCII platforms natively use the Unicode code points, this function returns its input on them. On EBCDIC platforms it converts from EBCDIC to Unicode. A meaningless value will currently be returned if the input is not an unsigned integer. Since Perl v5.22.0, calls to this function are optimized out on ASCII platforms, so there is no performance hit in using it there. =item * C<$native = utf8::unicode_to_native($code_point)> (Since Perl v5.8.0) This is the inverse of C, converting the other direction. Again, on ASCII platforms, this returns its input, but on EBCDIC platforms it will find the native platform code point, given any Unicode one. A meaningless value will currently be returned if the input is not an unsigned integer. Since Perl v5.22.0, calls to this function are optimized out on ASCII platforms, so there is no performance hit in using it there. =item * C<$flag = utf8::is_utf8($string)> (Since Perl 5.8.1) Test whether I<$string> is marked internally as encoded in UTF-8. Functionally the same as C. =item * C<$flag = utf8::valid($string)> [INTERNAL] Test whether I<$string> is in a consistent state regarding UTF-8. Will return true if it is well-formed UTF-8 and has the UTF-8 flag on B if I<$string> is held as bytes (both these states are 'consistent'). Main reason for this routine is to allow Perl's test suite to check that operations have left strings in a consistent state. You most probably want to use C instead. =back C is like C, but the UTF8 flag is cleared. See L, and the C API functions C>, C>, C>, and C>, which are wrapped by the Perl functions C, C, C and C. Also, the functions C, C, C, C, C, and C are actually internal, and thus always available, without a C statement. =head1 BUGS Some filesystems may not support UTF-8 file names, or they may be supported incompatibly with Perl. Therefore UTF-8 names that are visible to the filesystem, such as module names may not work. =head1 SEE ALSO L, L, L, L, L =cut