in reply to Re^2: UTF-8 and Unicode the hard way
in thread UTF-8 and Unicode the hard way

You shouldn't get a wide character in output error from your call to decode(...). Can you please show the relevant code and data that produces that output?

Replies are listed 'Best First'.
Re^4: UTF-8 and Unicode the hard way
by ikegami (Patriarch) on May 10, 2022 at 19:33 UTC

    produces a "wide character in output" error.

    hmm, are you saying your string is a garbage mix of UTF-8 and Unicode Code Points? Please provide the output of

    use Data::Dumper; local $Data::Dumper::Useqq = 1; print(Dumper($s));

    $answer = encode("UCS-2BE", $answer); results in \u0000 in front of EVERY character in output

    encode does not add the 6-charater string \u0000, but it should indeed add a zero byte in front of ASCII characters (and more).


    [Sorry, this was meant to be a reply to the OP, not Corion]