This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
encode()/decode() examples.
authorJarkko Hietaniemi <jhi@iki.fi>
Sun, 2 Dec 2001 00:25:35 +0000 (00:25 +0000)
committerJarkko Hietaniemi <jhi@iki.fi>
Sun, 2 Dec 2001 00:25:35 +0000 (00:25 +0000)
p4raw-id: //depot/perl@13421

ext/Encode/Encode.pm

index ddde0f2..76257d4 100644 (file)
@@ -700,6 +700,11 @@ Miscellaneous:
 Encodes string from Perl's internal form into I<ENCODING> and returns
 a sequence of octets.  For CHECK see L</"Handling Malformed Data">.
 
+For example to convert (internally UTF-8 encoded) Unicode data
+to octets:
+
+       $octets = encode("utf8", $unicode);
+
 =item *
 
         $string = decode(ENCODING, $bytes[, CHECK])
@@ -708,6 +713,10 @@ Decode sequence of octets assumed to be in I<ENCODING> into Perl's
 internal form and returns the resulting string.  For CHECK see
 L</"Handling Malformed Data">.
 
+For example to convert ISO 8859-1 data to UTF-8:
+
+       $utf8 = decode("latin1", $latin1);
+
 =item *
 
        from_to($string, FROM_ENCODING, TO_ENCODING[, CHECK])