24 lines
1.3 KiB
Plaintext
24 lines
1.3 KiB
Plaintext
' FB 1.05.0 Win64
|
|
|
|
Dim s As String = "moose" '' variable length ascii string
|
|
Dim f As String * 5 = "moose" '' fixed length ascii string (in practice a zero byte is appended)
|
|
Dim z As ZString * 6 = "moose" '' fixed length zero terminated ascii string
|
|
Dim w As WString * 6 = "møøse" '' fixed length zero terminated unicode string
|
|
|
|
' Variable length strings have a descriptor consisting of 3 Integers (12 bytes on 32 bit, 24 bytes on 64 bit systems)
|
|
' In order, the descriptor contains the address of the data, the memory currently used and the memory allocated
|
|
|
|
' In Windows, WString uses UCS-2 encoding (i.e. 2 bytes per character, surrogates are not supported)
|
|
' In Linux, WString uses UCS-4 encoding (i.e. 4 bytes per character)
|
|
|
|
' The Len function always returns the length of the string in characters
|
|
' The SizeOf function returns the bytes used (by the descriptor in the case of variable length strings)
|
|
|
|
Print "s : " ; s, "Character Length : "; Len(s), "Byte Length : "; Len(s); " (data)"
|
|
Print "s : " ; s, "Character Length : "; Len(s), "Byte Length : "; SizeOf(s); " (descriptor)"
|
|
Print "f : " ; f, "Character Length : "; Len(s), "Byte Length : "; SizeOf(f)
|
|
Print "z : " ; z, "Character Length : "; Len(s), "Byte Length : "; SizeOf(z)
|
|
Print "w : " ; w, "Character Length : "; Len(s), "Byte Length : "; SizeOf(w)
|
|
Print
|
|
Sleep
|