I have a string (read from a file) the is “encrypted” by XOR’ing each character with 0x99, which means I can decrypt it by doing the same thing again.
I am reading a file, and writing various results from the various fields into a text file. 99% of it is UINT16 values (file is loaded into a memory block)
If I SKIP these encoded strings, my output file is just what I want… but if I include them… the whole file goes bonkers (ie. Chinese glyphs), so I assume there is a change in encoding that occurs.
// read the string from the memory block
s=Decode(rawDATA.StringValue(ptr,optSize-1))
DECODE function
dim t as string
dim i as integer
dim c as integer
for i=1 to len(s) // has 0x00 on the end
c=ascb(mid(s,i,1)) xor &H99
t=t+chrb(c)
next i
t=t.ConvertEncoding(Encodings.UTF8) // including or excluding this line makes zero difference
// if I put a breakpoint here, T displays as the CORRECT value, but with an encoding of NIL
return t