Can someone explain to me how to encode the string "®" to base64 (I just picked any non-ASCII character to exemplify)? This char represents the code 174 or 10101110 in binary.
The result is "wq4=" (got this by checking in two different websites that do base64 encoding online).
I understand how the base64 encoding system works. For ASCII characters I can get the correct results but with any non-ASCII char, the result never matches.
I have tried two ways:
- Using directly the binary for this char (10101110) and splitting this into 2 chunks of 6 bits I have: 101011 and 100000. To base64 they correspond to "rg"
- Converting 10101110 to UTF-8 first so I have 2 bytes: 11010101 and 10110000. Then I mix these two bytes and separate them in chunks of 6 bits: 110101 011011 000000. To base64 they correspond to "1bA".
I have no idea how to proceed with non-ASCII characters. By doing the same calculation with any ASCII char, just works.
Does anyone know what I am doing wrong?