[Cuis-dev] String>>#readStream and FileEntry>>#readStream behave differently

Juan Vuletich juan at cuis.st
Mon May 20 08:56:41 PDT 2024


Hi Bernhard,

On 5/19/2024 4:33 PM, Bernhard Pieber via Cuis-dev wrote:
> Hi Juan,
>
> Thanks for fixing the issues so quickly.
>
> I may have found another one. Shouldn’t the last two entries in the resulting array be equal?
>
> | string |
> string := UnicodeString fromUtf8Bytes: #[57 57 194 160 226 130 172].
> DirectoryEntry userBaseDirectory at: 'test' put: string.
> {(DirectoryEntry userBaseDirectory at: 'test') = string. "Verify that file contents equals string"
> (string readStream upToAll: (string copyFrom: 3 to: 4)).
> (DirectoryEntry userBaseDirectory // 'test') readStream upToAll: (string copyFrom: 3 to: 4)}.
>
> Cheers,
> Bernhard

Yes. This is a bug. Good catch!

It is due to the fact that in UniFileStreams, even if reading Unicode 
code points, #position and #position: still refer to bytes, and 
therefore need to be used with care. I have fixed many of those calls in 
the past. I thought I'd fixed all of them! But I missed this one.

I've just pushed a fix, and turned your example into a test.

Thanks!

-- 
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich



More information about the Cuis-dev mailing list