Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Utf-8 Source Files and Unicode::String Basic information about using utf-8 Perl source files. This allows for string literals in any language to be used with Perl.
#The declaration "use utf8;" determines how the script source file containing it is
#interpreted. If this declaration is used, strings within the source file will be
#interpreted as being encoded in utf8.
use utf8;
# A Unicode::String object represents a sequence of Unicode characters. Methods are
# provided to convert between various external formats (encodings) and Unicode::String
# objects, and methods are provided for common string manipulations.
use Unicode::String qw(utf8 latin1 utf16);
$u = utf8("Is féidir liom gloinne a ithe. Ní dhéanann sí dochar ar bith dom.");
# If you run this script from an MS-DOS prompt, redirect the output to a file
# because the DOS console will not display the 8bit characters correctly...
# Even though the Perl source file is utf-8, we can emit in any character encoding.
print "Latin1: ", $u->latin1, "\n";
# Commented out code to emit in other encodings...
#print "UCS-4: ", $u->ucs4, "\n"; # 4 byte characters
#print "UTF-16: ", $u->utf16, "\n"; # 2 byte characters + surrogates
#print "UTF-8: ", $u->utf8, "\n"; # 1-4 byte characters
#print "UTF-7: ", $u->utf7, "\n"; # 7-bit clean format
#print "Hex: ", $u->hex, "\n"; # a hexadecimal string
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.