[Pharo-dev] Bug in ZnUTF8Encoder

Sven Van Caekenberghe sven at stfx.eu
Wed Apr 2 08:19:39 EDT 2014


Hi Igor,

Great catch ! How did you stumble upon this one ?

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 <siguctua at gmail.com> 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.





More information about the Pharo-dev mailing list