[Pharo-project] TextConverter handling of binary streams

Stéphane Ducasse stephane.ducasse at inria.fr
Tue Nov 30 12:20:17 CET 2010


fix fix fix :)

Stef

> I would even go further, the test UTF8TextConverterTest>>#testPutSingleCharacter is plain wrong, it seems to have been written as an afterthought:
> 
> testPutSingleCharacter
> 	| actual |
> 	actual := ByteArray streamContents: [ :stream |
> 		| converter |
> 		converter := UTF8TextConverter new.
> 		converter
> 			nextPut: $a
> 			toStream: stream.
> 		converter
> 			nextPut: (Unicode value: 16r20AC)
> 			toStream: stream ].
> 	self assert: actual = #[97 0 0 32 172]
> 
> The correct result is #[97 226 130 172] !!
> 
> If you would give these bytes to any other system, they would never be able to decode them as UTF-8.





More information about the Pharo-project mailing list