cppdev
cppdev

Reputation: 6973

Can base64 encoding applied to multibyte utf-8 characters?

Can base64 encoding applied to multibyte utf-8 characters ? How base64 encoded string is converted back to multibyte utf-8 string ?

Upvotes: 3

Views: 3601

Answers (3)

Rio Bautista
Rio Bautista

Reputation: 443

Yes, I use base64 to wrap my multi-byte text into a byte array that is easier to transmit over HTTP without loss. I can also store my text on any database platform regardless of collation and preserve the exact text without loss.

You can then decode the byte-array back into text exactly as it were at the receiving end BUT! this is of course assuming your receiving end is capable of displaying the text as it was captured. For example in my case, from one IOS device to another IOS device.

It's another issue if you wanted to display an IOS captured text out to a PHP page without loosing the emojis and multibyte characters. That's already a matter of String encoding e.g. UTF-8, etc.

Upvotes: 0

zaf
zaf

Reputation: 23264

base64 does not care. You can use base64 encode and then decode to get back where you were.

Upvotes: 1

wRAR
wRAR

Reputation: 25559

base64 is applied to bytes, not characters. It's up to your application to convert your strings, utf8 or not, to their bytes representation.

Upvotes: 3

Related Questions