RosettaCodeData/Task/String-length/BBC-BASIC/string-length-2.bbc

13 lines
502 B
Plaintext

CP_ACP = 0
CP_UTF8 = &FDE9
textA$ = "møøse"
textW$ = " "
textU$ = " "
SYS "MultiByteToWideChar", CP_ACP, 0, textA$, -1, !^textW$, LEN(textW$)/2 TO nW%
SYS "WideCharToMultiByte", CP_UTF8, 0, textW$, -1, !^textU$, LEN(textU$), 0, 0
PRINT "Length in bytes (ANSI encoding) = " ; LEN(textA$)
PRINT "Length in bytes (UTF-16 encoding) = " ; 2*(nW%-1)
PRINT "Length in bytes (UTF-8 encoding) = " ; LEN($$!^textU$)