[Seaside-dev] testCodecLatin1 and testCodecUtf8Bom

Paolo Bonzini bonzini at gnu.org
Sun May 16 07:08:35 UTC 2010


On Sat, May 15, 2010 at 01:19, Michael Lucas-Smith
<mlucas-smith at cincom.com> wrote:
> Hi All,
>
> #testCodecLatin1 and #testCodecUtf8Bom fail for me on VisualWorks.. once the
> Unicode string is created, #asByteArray is sent to it to "turn it back to
> bytes" but of course this is impossible, it's already a TwoByteString in
> VisualWorks and to turn that back to bytes, you need to specify an encoding
> using #asByteArrayEncoding: 'utf-8' (for example).

Maybe instead of

 self assert: (codec decode: bom , self utf8String) asByteArray
     = self decodedString asByteArray.

we need

 self assert: (codec encode: (codec decode: bom , self utf8String))
     = (codec encode: self decodedString).

> Can these tests be written with a custom compare operation?

That too; however:

> the comment in
> #testCodecLatin1 explains the problem - that comparing unicode strings using
> #= is not necessarily going to work across platforms, but perhaps something
> like this might work everywhere:
>
> compare: a with: b
>   a size = b size ifFalse: [^false].
>   1 to: a size do: [:index | (a at: index) = (b at: index) ifFalse:
> [^false]].
>   ^true

That would be the same as #=, wouldn't it?  Is comparing unicode
strings using #= not portable *if we know the two strings have the
same encoding* or at least were produced by the same codec?

Paolo


More information about the seaside-dev mailing list