How large is a chr?

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

Tibit(Posted 2005) [#1]
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 ?


Perturbatio(Posted 2005) [#2]
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.


Tibit(Posted 2005) [#3]
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 =)


Floyd(Posted 2005) [#4]
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)



Cajun17(Posted 2005) [#5]
Doesn't bmax use unicode since it's x-platform? That would explain why each char is 2 bytes.


Tibit(Posted 2005) [#6]
Wait does this mean a string on lenght 10 is 20 bytes large and not 10 as in Blitz3D?


BlitzSupport(Posted 2005) [#7]

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).