Overview
| Artifact ID: | c37cc107ef217cec81c139ac74f70de4c7ae57e20d990579506cc2ca334dc382 |
|---|---|
| Ticket: | b5cb29c639a5dab3b03e4d8827e7d4ab9b05ae61
utf-8 from&to and / binary encoding&decodeing conversation not the same |
| User & Date: | oehhar on 2019-02-22 10:05:44 |
Changes
- icomment:
Dear amitego, you need binary data (bytes) for "binary encode base64". If you feed-in non-ninary data, the result is undefined. Lets take the string "ä". This is one character of the unicode codepoint \u00e4. By chance, the value is below \u00ff, so a conversion to binary does not harm and the character passes. Lets take the character "š". This is one character of the unicode codepoint \u0161. If this is treated as binary, only the lower byte is retained. This results in \u0061 which corresponds to the character "a". You observe this transformation in your example. To transform a string into binary data, an encoding is required. If you choose "utf-8", you get: <verbatim> % set u [encoding convertto utf-8 š] Å¡ % string length $u 2 % scan $u %c%c 197 161 </verbatim> This representation may be used by binary encode. I hope, it is getting clearer what happens. It is difficult but very powerful. Hope this helps, Harald
- login: "oehhar"
- mimetype: "text/x-fossil-wiki"
- username: "oehhar"