Welcome to WebmasterWorld Guest from 54.166.224.46

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

how to print unicode in a perl script

how to print uniode in a perl script

     
5:10 pm on May 12, 2004 (gmt 0)

10+ Year Member



I hope this is a easy question ..

i have made a test perl script that prints out
a html page and in one frame i wish to
print unicode so it shows the unicode code in the page.
Without the page converting the code back

so the code must remain code .. not hmtl /text..

so the out put will be a webpage that
shows in a table some unicode

i hope you udnerstand what i mean ..

i try this .. but it still prints the unicode as html not as code

#### sample #####

#!/usr/local/bin/perl
print "Content-Type: text/html\n\n";

print <<HTML_A;
<HTML>
<HEAD>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<CENTER><BR>
here is a sample of the unicode<BR>
<BR>
<TABLE BORDER=1 WIDTH="66%">
<TR>
<TD>
<CENTER>
HTML_A

#### html sample here #####

print "&#119;&#101;&#98;&#109;&#97;&#115;&#116;&#101;&#114;&#64;&#109;&#121;&#83;&#105;&#116;&#101;&#46;&#99;&#111;&#109;\n";

#### End html sample #####

print <<HTML_B;
</TD>
</TR>
</TABLE>
<BR>
<BR>
copy and past the code</CENTER>
</BODY>
</HTML>

HTML_B

exit;

6:59 pm on May 12, 2004 (gmt 0)

10+ Year Member



You could replace the & symbol with its html code counterpart in the string:


$unicode = '&#119;&#101;&#98;&#109;&#97;';
$unicode =~ s/&/&#38;/g;

The $unicode string when printed in a browser would look normal for copy-and-paste operations.

7:39 pm on May 12, 2004 (gmt 0)

10+ Year Member



thank you very mush : VectorJ

This works perfectly :-)
i would myself never thought of this trick ....

 

Featured Threads

Hot Threads This Week

Hot Threads This Month