in reply to How to Use Pack to Convert UTF-16 Surrogate Pairs to UTF-8?
I would really like a solution that just uses pack without having to use any additional libraries (JSON::XS, Encode, etc.).
Why? This very much smells like an X/Y problem to me. JSON::PP has been in the core for over 11 years (since Perl 5.14).
use warnings; use strict; use JSON::PP; use Data::Dump; my $enc = '"Alice \ud83d\ude06 Bob"'; my $json = JSON::PP->new->allow_nonref; dd $json->decode($enc); # "Alice \x{1F606} Bob"
Minor edit for clarification.
|
|---|