On 11 Jun 2014, at 10:28 , Sven Van Caekenberghe <s...@stfx.eu> wrote:
> Bonsoir François, > > From the class comment of ZnBase64Encoder: > > [...] > Note that to encode a String as Base64, you first have to encode the > characters as bytes using a character encoder. > [...] > > Sending #asByteArray to a String is the same as doing no encoding (or doing > null encoding). > > Consider: > > ZnBase64Encoder new encode: (ZnUTF8Encoder new encodeString: > 'tamèreenslipdeguerre'). > > => 'dGFtw6hyZWVuc2xpcGRlZ3VlcnJl' > > ZnBase64Encoder new encode: (ZnByteEncoder iso88591 encodeString: > 'tamèreenslipdeguerre'). > > => 'dGFt6HJlZW5zbGlwZGVndWVycmU=' > > ZnBase64Encoder new encode: (ZnNullEncoder new encodeString: > 'tamèreenslipdeguerre'). > > => 'dGFt6HJlZW5zbGlwZGVndWVycmU=' > > The last two are often the same, and thus equivalent to #asByteArray, but not > always. > > HTH, > > Sven In other words, Base64 isn’t really an encoding, it’s a transfer format, whose purpose is to only transmit bytes with "safe" values that have no chance of being interpreted as control sequences by a set of protocols. Encoding Strings -> Bytes is a separate concern. Cheers, Henry
signature.asc
Description: Message signed with OpenPGP using GPGMail