Assuming the hex string isrepresents UTF-8, you could do this:
use warnings; use strict; use open qw/:std :utf8/; use HTML::Entities qw/decode_entities/; my $x = '리작'; my $xd = decode_entities($x); my $y = '\\xeb\\xa6\\xac\\xec\\x9e\\x91'; (my $yd = $y) =~ s/\\x([0-9a-f]{2})/chr hex $1/eig; utf8::decode($yd); print "$x =>$xd<=\n"; print "$y =>$yd<=\n"; if ( $xd eq $yd ) { print "Match!\n" } else { die "Mismatch!\n" }
Output:
리작 =>리작<= \xeb\xa6\xac\xec\x9e\x91 =>리작<= Match!
Update: I realized it's unclear to me whether your original string was player=리작 or player=리작 - the latter happens on PerlMonks when you put Unicode characters into <code> tags. You'd have to use <pre> or <tt> tags instead, but then characters that have special meanings (either as HTML or by the PerlMonks engine) have to be escaped, such as <=>, &=&, [=[, etc. If your original string was player=리작, then you don't need the decode_entities step - but it is necessary for the input string in $cfg{'default.player'} to have been properly decoded first though (you can check this e.g. with Devel::Peek, see also).
In reply to Re: Comparing string hex / korean (updated)
by haukex
in thread Comparing string hex / korean
by pax77
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |