Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
23
Task/String-length/FreeBASIC/string-length.freebasic
Normal file
23
Task/String-length/FreeBASIC/string-length.freebasic
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
' 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue