Ok so that should work given the string has utf8 flag set.
I guess the problem may be that my string doesn't have it set.
I'm getting the string as output from XML::DOM::Document->toString, so I
should investigate with that module why isn't setting the utf8 flag.
Thanks
Aaron
-----Original Message-----
From: Nick Ing-Simmons [mailto:nick(_at_)ing-simmons(_dot_)net]
Sent: Wednesday, October 27, 2004 5:25 AM
To: aaron(_at_)starwoodhotels(_dot_)com
Cc: 'perl-unicode(_at_)perl(_dot_)org'
Subject: Re: Question about converting utf8 to ascii and char refs
Aaron Siladi <aaron(_at_)starwoodhotels(_dot_)com> writes:
I have a UTF-8 string which I want to output as ascii and have the UTF8
characters converted to numeric character references.
I tried using Encode with the FB_HTMLCREFS fail back option enabled, but
for
the 2 byte UTF8 characters, 2 incorrect char refs were printed out instead
of the correct one.
You mean like this:
--------------------------------------
#!perl
use Encode;
my $s = chr(0x100)."4";
my $n = encode('ascii',$s,Encode::FB_HTMLCREF);
print "$n\n";
__END__
----------------------------------------------
Works for me:
nick(_at_)llama:/home/p4work/mail> perl /tmp/try
Ā4
Any help is greatly appreciated
Thanks
Aaron
This electronic message transmission contains information from the Company
that may be proprietary, confidential and/or privileged.
The information is intended only for the use of the individual(s) or entity
named above. If you are not the intended recipient, be
aware that any disclosure, copying or distribution or use of the contents
of this information is prohibited. If you have received
this electronic transmission in error, please notify the sender immediately
by replying to the address listed in the "From:" field.
This electronic message transmission contains information from the Company that
may be proprietary, confidential and/or privileged.
The information is intended only for the use of the individual(s) or entity
named above. If you are not the intended recipient, be
aware that any disclosure, copying or distribution or use of the contents of
this information is prohibited. If you have received
this electronic transmission in error, please notify the sender immediately by
replying to the address listed in the "From:" field.