RosettaCodeData/Task/String-length/M2000-Interpreter/string-length.m2000
2026-04-30 12:34:36 -04:00

21 lines
698 B
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module String_length {
A$=format$("J\u0332o\u0332s\u0332e\u0301\u0332")
Print Len(A$) = 9 ' true Utf-16LE
Print Len.Disp(A$) = 4 \\ display length
Buffer Clear Mem as Byte*100
Buffer Mem2 as Integer*50
Mem[0]=A$
Print Eval$(Mem, 0, 18) ' 18 bytes from Mem[0] as a string
Mem2[0]=Mem
For i=0 to 8
Hex Mem2[i], ChrCode$(Mem2[i])
Next i
// Check as UTF8 (UTFEnc and UTF8Dec are selections for string$())
Print len(string$(A$ as UTF8Enc))*2=14 ' bytes
Locale 1033
// to ANSI and back to UTF16LE (destructive)
Print chr$(str$(A$))="J_o_s_e´_" ' true
Print A$;POS=4 ' J̲o̲s̲é̲True
Print String$(A$ as Json)="J\u0332o\u0332s\u0332e\u0301\u0332" ' True
}
String_length