monkey2 icon indicating copy to clipboard operation
monkey2 copied to clipboard

Databuffer.PeekString issue

Open jondecker76 opened this issue 7 years ago • 1 comments

Please see forum post here: http://monkeycoder.co.nz/forums/topic/help-porting-hmac-sha256-code/#post-15930

String characters $80 to $FE are returned as $FF80 to FFFE. There is no $FF character at all, and $00 is returned. This makes any type of string based encryption/hashing very difficult. Is this a bug?

jondecker76 avatar Jan 17 '19 01:01 jondecker76

Strings in Monkey2 support Unicode and each Character uses 16Bit = 2 Bytes.

Your code looks to me like you assume ASCII-Strings?

Maybe there should be some more PeekString() functions to catch different String representations from DataBuffer.

DataBuffer.PeekString(offset, count, StringFormat.ASCII )
DataBuffer.PeekString(offset, count, StringFormat.UTF8 )
DataBuffer.PeekString(offset, count, StringFormat.UTF16 )
...

Currently it looks like PeekString() indeed catches ASCII chars, but that would be wrong imo.

D-a-n-i-l-o avatar Jan 17 '19 10:01 D-a-n-i-l-o