X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperluniintro.pod;h=81efd6bba4cba421de9a847b31bb8b9f9245affe;hb=7b667b5fb1c41f31aff1e46b9f74e36eb063010e;hp=803df80759f4db7eac728520793b0a95e1554c46;hpb=c0c50798904ed219d069da8d28f789f4cc6e4fb2;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perluniintro.pod b/pod/perluniintro.pod index 803df80..81efd6b 100644 --- a/pod/perluniintro.pod +++ b/pod/perluniintro.pod @@ -246,16 +246,14 @@ Note that both C<\x{...}> and C<\N{...}> are compile-time string constants: you cannot use variables in them. if you want similar run-time functionality, use C and C. -Also note that if all the code points for pack "U" are below 0x100, -bytes will be generated, just like if you were using C. - - my $bytes = pack("U*", 0x80, 0xFF); - If you want to force the result to Unicode characters, use the special C<"U0"> prefix. It consumes no arguments but forces the result to be in Unicode characters, instead of bytes. - my $chars = pack("U0U*", 0x80, 0xFF); + my $chars = pack("U0C*", 0x80, 0x42); + +Likewise, you can force the result to be bytes by using the special +C<"C0"> prefix. =head2 Handling Unicode @@ -670,8 +668,8 @@ How Do I Detect Data That's Not Valid In a Particular Encoding? Use the C package to try converting it. For example, - use Encode 'encode_utf8'; - if (encode_utf8($string_of_bytes_that_I_think_is_utf8)) { + use Encode 'decode_utf8'; + if (decode_utf8($string_of_bytes_that_I_think_is_utf8)) { # valid } else { # invalid