On 2 April 2014 14:19, Sven Van Caekenberghe <[email protected]> wrote:

> Hi Igor,
>
> Great catch ! How did you stumble upon this one ?
>
> Just showing Max (my new room mate) to implement utf-8 encoding using
Virtual CPU DSL, and using your code as an example.

And ya, my sharp eye with perfect precision immediately detected the
problem.... (hope it sounds arrogant enough) ;)

Frankly, i don't know. What i think is, that i seen comparison with powers
of two numbers in my life so many times, that i trained to automatically
see if it correct or not. :)


> Anyway, it shows that unless you really test all boundaries explicitly,
> silly one-off errors like that manage to survive for quite some time. I
> added a unit test doing just that.
>
> Fixed upstream:
>
> ===
> Name: Zinc-Character-Encoding-Core-SvenVanCaekenberghe.31
> Author: SvenVanCaekenberghe
> Time: 2 April 2014, 2:14:36.890651 pm
> UUID: 3f6ae285-2973-4451-833b-16afbd0658d3
> Ancestors: Zinc-Character-Encoding-Core-SvenVanCaekenberghe.30
>
> Fixed a one-off error in ZnUTF8Encoder>>#nextPut:toStream (thanks Igor
> Stasenko)
> ===
> Name: Zinc-Character-Encoding-Tests-SvenVanCaekenberghe.18
> Author: SvenVanCaekenberghe
> Time: 2 April 2014, 2:15:51.938152 pm
> UUID: c7048056-52ae-484f-a466-7d537f66690a
> Ancestors: Zinc-Character-Encoding-Tests-SvenVanCaekenberghe.17
>
> Fixed a one-off error in ZnUTF8Encoder>>#nextPut:toStream (thanks Igor
> Stasenko)
>
> Added ZnCharacterEncoderTests>>#testUTF8Boundaries
> ===
>
> Thanks again,
>
> Sven
>
> On 02 Apr 2014, at 13:18, Igor Stasenko <[email protected]> wrote:
>
> > nextPut: character toStream: stream
> > ...
> > code < 65535 ifTrue: [
> > ...
> >
> > should be
> >
> > code < 65536 ifTrue: [
> >
> > because 3-byte encoding can fit 16 bits, which is range
> > 0...65535
> > but not
> > 0...65534
> >
> > --
> > Best regards,
> > Igor Stasenko.
>
>
>


-- 
Best regards,
Igor Stasenko.

Reply via email to