Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unicode to hex conversion

Status
Not open for further replies.

hamptonk

Programmer
Oct 20, 2007
1
US
Greetings,

I've tried everything, read everything, and i can't figure out how to
convert by unicode strings to hex?

&u03B8;&u03B5;&u1F79;&u03C0;&u03BD;&u03B5;&u03C5;&u03C3;&u03C4;&u03BF;&u03C2;
back to
&#XXXX;&#XXXX;&#XXXX;&#XXXX;&#XXXX;&#XXXX;etc


while (<INFILE>){
$body = $_;
$body =~ s{<(heb|grc|arc)>(.*?)<\/\1>}
{
my $prefix=$1;
my $return=$2;
for ($return) {
s{\&\u(.*?);}
{
$u = $1;
#DO SOMETHING HERE?
"\&#$u;";
}ge;
}
"<$prefix>$return</$prefix>"
}ge;


this goes from hex to unicode if that helps

$body =~ s{\&\#(\d+);}
{
my $hex = sprintf "%04lX", $1;
"\&u$hex;"
}ge;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top