Chr(0,#ENCODING_RAW)
Chr(0,#ENCODING_RAW)
I expected Chr(n,#ENCODING_RAW) and ByteChr(n) to return the same result, but Chr(0,#ENCODING_RAW) returns an empty string. Is that correct?
Re: Chr(0,#ENCODING_RAW)
how do you check it ? look same to me
dont forget strings terminated with a 0
edit
correct myself, Chr is a code point converter , so its 0 which is alreay an empty string (string terminate with 0 so zero is emptty string anyway
bytechr add the value to the string which is a single byte 0 since its an empty string, but because bytechr add the value blind it continue to add zeros
thereofore its a zero to a zero terminated string aka 2 bytes
this example show it
dont forget strings terminated with a 0
edit
correct myself, Chr is a code point converter , so its 0 which is alreay an empty string (string terminate with 0 so zero is emptty string anyway
bytechr add the value to the string which is a single byte 0 since its an empty string, but because bytechr add the value blind it continue to add zeros
thereofore its a zero to a zero terminated string aka 2 bytes
this example show it
Code: Select all
For i=1 To 10
strs = strs .. Chr(0,#ENCODING_RAW)
Next
DebugPrint(StrLen(strs))
For i=1 To 10
strs2 = strs2 .. ByteChr(0)
Next
DebugPrint(StrLen(strs2))
Christos
Re: Chr(0,#ENCODING_RAW)
This is Hollywood, not C . In Hollywood strings can contain binary data, this would not be possible with zero terminated strings. From the manual:
"In many programming languages a zero character defines the end of the string. Not so in Hollywood. Hollywood allows you to use as many zero characters as you want in your strings."
- airsoftsoftwair
- Posts: 5454
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Chr(0,#ENCODING_RAW)
Yes, I think the behaviour is wrong. I'll check, thanks for the report!