Came across this potential bug.
As you'll hopefully be able to reproduce, when the calculation is put directly inside chr(), it generates two characters instead of one, but putting the calculation into a unicode .u variable first and then calling chr() on it works fine.
Tested with 6.01 lts (64/32 bit, c/asm), and 6.03 beta 3 (windows 64/32 bit, c/asm).
Code: Select all
EnableExplicit
Define a.u=(((120000-65536)>>9)+55192)
Debug a; 55298
Define c$=Chr(a)
Debug c$; character 55298 (0xd802)
Debug Len(c$); 1
Define u=PeekU(@c$)
Debug ""+u+" (0x"+Hex(u, #PB_Unicode)+")"
Debug (((120000-65536)>>9)+55192); 55298
c$=Chr((((120000-65536)>>9)+55192))
Debug c$; two 65553 characters (0xfffd)
Debug Len(c$); 2
u=PeekU(@c$)
Debug ""+u+" (0x"+Hex(u, #PB_Unicode)+")"
u=PeekU(@c$+SizeOf(character))
Debug ""+u+" (0x"+Hex(u, #PB_Unicode)+")"
Debug Bin(a, #PB_Unicode); 1101100000000010
Debug Bin((((120000-65536)>>9)+55192), #PB_Unicode); 1101100000000010