Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Base64ing Unicode characters

Tags:

unicode

base64

Can Unicode characters be encoded and decoded with Base64?

I have attempted to encode the string 'الله', but when I decoded it all I got was '????'.

like image 681
UnkwnTech Avatar asked Nov 20 '08 12:11

UnkwnTech


People also ask

Can Base64 encode Unicode?

Of course they can. It depends on how your language or Base64 routine handles Unicode input. For example, Python's b64 routines expect an encoded string (as Base64 encodes binary to text, not Unicode codepoints to text).

What is Base64 encoding used for?

Base64 encoding schemes are commonly used when there is a need to encode binary data that needs to be stored and transferred over media that are designed to deal with ASCII. This is to ensure that the data remain intact without modification during transport.


1 Answers

Base64 converts binary to text. If you want to convert text to a base64 format, you'll need to convert the text to binary using some appropriate encoding (e.g. UTF-8, UTF-16) first.

like image 78
Jon Skeet Avatar answered Sep 18 '22 14:09

Jon Skeet