Сохранение текста в UTF-8
- 0 TEXT$="Текст в utf8"
- 10 TRAP 120
- 20 OPEN #1,"file:///c:/other/utf.txt","output"
- 30 LEN%=LEN(TEXT$)
- 40 FOR I%=1 TO LEN%
- 50 C%=ASC(MID$(TEXT$,I%,1))
- 60 IF NOT C%=0 AND C%<128 THEN PUT #1,C%:GOTO 110
- 70 IF C%=0 OR C%>=128 AND C%<2048 THEN PUT #1,192 BITOR (31 BITAND (C%/64)):PUT #1,128 BITOR (63 BITAND C%):GOTO 110
- 80 PUT #1,224 BITOR (15 BITAND (C%/4096))
- 90 PUT #1,128 BITOR (63 BITAND (C%/64))
- 100 PUT #1,128 BITOR (63 BITAND C%)
- 110 NEXT I%
- 120 CLOSE #1:PRINT "ok"