Oh stupid me!��
Thanks a lot Sven, crystal clear explanations (and class comments!), as always :)



On Wed, Jun 11, 2014 at 10:28 PM, Sven Van Caekenberghe <sven@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

On 11 Jun 2014, at 21:56, Fran��ois Stephany <tulipe.moutarde@gmail.com> wrote:

> I might hit some problem with Base64 encoding in there.
> It seems that Pharo does not use UTF8 for its Base64 encoding.
>
> I'm probably missing something related to Base64 encoding...
>
> In Pharo 3.0:
>
> ZnBase64Encoder new encode: 'tam��reenslipdeguerre' asByteArray.
> -> 'dGFt6HJlZW5zbGlwZGVndWVycmU='
>
> 'tam��reenslipdeguerre' base64Encoded.
> -> 'dGFt6HJlZW5zbGlwZGVndWVycmU='
>
> In Ruby 2.0:
>
> Base64.strict_encode64("tam��reenslipdeguerre")
> -> dGFtw6hyZWVuc2xpcGRlZ3VlcnJl
>
> http://www.motobit.com/util/base64-decoder-encoder.asp
> (iso-8859-1)
> tam��reenslipdeguerre -> dGFt6HJlZW5zbGlwZGVndWVycmU=
>
> http://www.motobit.com/util/base64-decoder-encoder.asp
> (utf8)
> -tam��reenslipdeguerre > dGFtw6hyZWVuc2xpcGRlZ3VlcnJl