in reply to decode/encode - can someone explain this please
The internal arrangement of a scalar is no relevance to this conversation. It's the string in the scalar that matters.
A string can be text, UTF-8, iso-latin-1, a packed integer. In fact, it's suppose to be able to hold any sequence of 32-bit or 64-bit integers (depending on your build).
Your string apparently contains text encoded into bytes using UTF-8 (UTF-8 text), but encode requires decoded Unicode text. You can get what you need from what you have using decode.
Update: Removed a distracting paragraph.
|
|---|