I am so confused by the unicode and unicode in perl.
I got this hash from MySQL db.
my $hashFromDB = { "Ves\x{101}kha" => "some value" };
But I only know the key in this form of notation
my $key = "Ves\u0101kha";
How can I convert that \uXXXX notation to that \x{xxx} so that I can get the value with the key.
Thanks.
\x{}escape in Perl works almost exactly like\uescape in JS. You simply use code inside{}, exactly as in your first snippet:If you have literal string with
\uin it, which I assume means “\u followed with 4 hexadecimal digits to form codepoint number”, just preprocess it with regexp that would replace such sequences with real characters with same code:BTW,
\uhave different meaning in Perl – it upercases next symbol. You can check complete list of escapes in documentation.