Bytes in the source text that have their high-bit set will be treated
as being part of a literal UTF-8 character. This includes most
literals such as identifier names, string constants, and constant
-regular expression patterns. On EBCDIC platforms characters in
-the Latin 1 character set are treated as being part of a literal
-UTF-EBCDIC character.
+regular expression patterns.
+
+On EBCDIC platforms characters in the Latin 1 character set are
+treated as being part of a literal UTF-EBCDIC character.
=back
and utf8::downgrade are always available, without a C<require utf8>
statement-- this may change in future releases.
+=head1 BUGS
+
+One can have Unicode in identifier names, but not in package/class or
+subroutine names. While some limited functionality towards this does
+exist as of Perl 5.8.0, that is more accidental than designed; use of
+Unicode for the said purposes is unsupported.
+
+One reason of this unfinishedness is its (currently) inherent
+unportability: since both package names and subroutine names may need
+to be mapped to file and directory names, the Unicode capability of
+the filesystem becomes important-- and there unfortunately aren't
+portable answers.
+
=head1 SEE ALSO
L<perlunicode>, L<bytes>
./perl -Ilib ext/Time/HiRes/HiRes.t
+=head2 Unicode in package/class and subroutine names does not work
+
+One can have Unicode in identifier names, but not in package/class or
+subroutine names. While some limited functionality towards this does
+exist as of Perl 5.8.0, that is more accidental than designed; use of
+Unicode for the said purposes is unsupported.
+
+One reason of this unfinishedness is its (currently) inherent
+unportability: since both package names and subroutine names may
+need to be mapped to file and directory names, the Unicode capability
+of the filesystem becomes important-- and there unfortunately aren't
+portable answers.
+
=head2 UNICOS/mk
=over 4
UTF-8 in package names and sub names? The first is problematic
because of the mapping to pathnames, ditto for the second one if
-one does autosplitting, for example.
+one does autosplitting, for example. Some of this works already
+in 5.8.0, but essentially it is unsupported. Constructs to consider,
+at the very least:
+
+ use utf8;
+ package UnicodePackage;
+ sub new { bless {}, shift };
+ sub UnicodeMethod1 { ... $_[0]->UnicodeMethod2(...) ... }
+ sub UnicodeMethod2 { ... } # in here caller(0) should contain Unicode
+ ...
+ package main;
+ my $x = UnicodePackage->new;
+ print ref $x, "\n"; # should be Unicode
+ $x->UnicodeMethod1(...);
+ my $y = UnicodeMethod3 UnicodePackage ...;
+
+In the above all I<UnicodeXxx> contain (identifier-worthy) characters
+beyond the code point 255, for example 256. Wherever package/class or
+subroutine names can be returned needs to be checked for Unicodeness.
=back
(in string or regular expression literals, or in identifier names) on
ASCII-based machines or to recognize UTF-EBCDIC on EBCDIC-based
machines. B<These are the only times when an explicit C<use utf8>
-is needed.>
+is needed.> See L<utf8>.
You can also use the C<encoding> pragma to change the default encoding
of the data in your script; see L<encoding>.
needed: if your Perl script itself is encoded in UTF-8, you can use
UTF-8 in your identifier names, and in string and regular expression
literals, by saying C<use utf8>. This is not the default because
-scripts with legacy 8-bit data in them would break.
+scripts with legacy 8-bit data in them would break. See L<utf8>.
=head2 Perl's Unicode Model
* Method if it's "foo $bar"
* Not a method if it's really "print foo $bar"
* Method if it's really "foo package::" (interpreted as package->foo)
- * Not a method if bar is known to be a subroutne ("sub bar; foo bar")
+ * Not a method if bar is known to be a subroutine ("sub bar; foo bar")
* Not a method if bar is a filehandle or package, but is quoted with
* =>
*/
CLINE;
yylval.opval = (OP*)newSVOP(OP_CONST, 0, sv);
yylval.opval->op_private = OPpCONST_BARE;
+ /* UTF-8 package name? */
+ if (UTF && !IN_BYTES &&
+ is_utf8_string((U8*)SvPVX(sv), SvCUR(sv)))
+ SvUTF8_on(sv);
/* And if "Foo::", then that's what it certainly is. */