Re: About HTML unicode

[email protected] (Ben Morrow)
Newsgroups perl.unicode
Organization Very poor.
Message-ID <[email protected]>
Quoth [email protected] (He Zhiqiang):
> 
>  I've a problem to convert a unicode character into it's decimal or 
> Hexadecimal value. The following URL:
> http://code.cside.com/3rdpage/us/unicode/converter.html
>  can easily convert via Javascript function escape(), but i wonder that is 
> there some method or function
> or modules can do the same job?? If i can do it, then in one html page, i 
> can display ont only chinese, but
> also japanese, korea etc... This is something like HTML unicode, am i right? 

I routinely use

use Encode qw/:fallbacks/;
use PerlIO::encoding ();

$PerlIO::encoding::fallback = FB_XMLCREF; # could use HTMLCREF instead
binmode STDOUT, ':encoding(ascii)';

which will cause all non-ascii characters in the output to be converted
to HTML's &#xF00; form. You need 5.8 for this to work, but you need 5.8
for Unicode support anyway.

(if this is wrong, could someone tell me where, and why... ? :)

>  The ord() function can't do the job because it return the incorrect decimal 

I presume you mean 'the ord function returns the decimal value, which is
not what I want (I want the hex value)' rather than 'the ord function
returns an incorrect decimal value (i.e. the value itself is wrong)'?

Ben

-- 
Every twenty-four hours about 34k children die from the effects of poverty.
Meanwhile, the latest estimate is that 2800 people died on 9/11, so it's like
that image, that ghastly, grey-billowing, double-barrelled fall, repeated
twelve times every day. Full of children. [Iain Banks]         [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.