Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
HTML Entity Encode and Decode
Perl script to HTML entity encode and decode strings. #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; use chilkat; $s = new chilkat::CkString(); $s->appendUtf8("Is féidir liom gloinne a ithe. Ní dhéanann sí dochar ar bith dom."); $s->entityEncode(); # Note: Printing to the DOS console requires the OEM code page, # which is ibm850 on US and Western European computers... # Prints: "Is féidir liom gloinne a ithe. Ní dhéanann sí dochar ar bith dom." print($s->getEnc("ibm850") . "\n"); # Now decode the entities... $s->entityDecode(); # Prints: "Is féidir liom gloinne a ithe. Ní dhéanann sí dochar ar bith dom." print($s->getEnc("ibm850") . "\n"); # PS: Here are ways to get the string into a PERL string variable # in the encoding of your choice... $s1 = $s->getUtf8(); $s2 = $s->getAnsi(); $s3 = $s->getEnc("iso-8859-1"); $s4 = $s->getEnc("ebcdic"); |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.