How large is a chr?

BlitzMax Forums/BlitzMax Programming/How large is a chr?

Chr returns a String of length 1 containing the unicode character of the value. - BMax Manual


LongChr$ = Chr(123456)
Print LongChr 'Looks like it takes 3 bytes
Print "LongChr Len: "+Len(LongChr)'But still counts as 1

Always had the idea a char is a byte 0-255 ?

m$ = Chr(65)
Print m
Print "len:"+Len(m)

1 byte

you are sending a value larger than the standard ascii table goes.
I don't know if that is intentional (for extended character sets) or a bug.

I don't know if that is intentional (for extended character sets) or a bug.

That's what I meant. Because it is actually very handy =)

Chr(65) is string consisting of a single character. So the string length is 1.

But each character is two bytes.
s$ = "ABCD"

Print
Print "Length = " + Len(s)
Print "#bytes = " + SizeOf(s)


Doesn't bmax use unicode since it's x-platform? That would explain why each char is 2 bytes.

Wait does this mean a string on lenght 10 is 20 bytes large and not 10 as in Blitz3D?


Wait does this mean a string on lenght 10 is 20 bytes large and not 10 as in Blitz3D?


Yep, run SizeOf on it to see ("Print SizeOf (a$)"). Blitz strings are Unicode to allow support for non-English character sets, ie. those outside the normal ASCII range of a single byte (Mark has to update DrawText to allow them to be displayed though).