C strings always end with a null char, even other languages do this too.
And exactly this is my problem - I don't want to have a C string, I want to have a byte or short array. Something like this would help me:
Strict
Function StringToShortArray:Short [] ( S$ )
Local Shorts:Short [ Len S ]
MemCopy Shorts , 4 + Byte Ptr Object S , 2 * Len Shorts
Return Shorts
EndFunction
Function StringToShorts ( S$ , Shorts:Short Ptr )
MemCopy Shorts , 4 + Byte Ptr Object S , 2 * Len S
EndFunction
Function StringToByteArray:Byte [] ( S$ )
Local Bytes:Byte [ Len S ]
For Local I = 0 Until Len S
Bytes [ I ] = S [ I ]
Next
Return Bytes
EndFunction
Function StringToBytes ( S$ , Bytes:Byte Ptr )
For Local I = 0 Until Len S
Bytes [ I ] = S [ I ]
Next
EndFunctionI could write a module for this.
But I don't really want to write a module for only four functions.