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 = '&#47532;&#51089;'; 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:

&#47532;&#51089; =>리작<=
\xeb\xa6\xac\xec\x9e\x91 =>리작<=
Match!

Update: I realized it's unclear to me whether your original string was player=리작 or player=&#47532;&#51089; - 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 <=&gt;, &=&amp;, [=&#91;, 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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.