Сохранение текста в UTF-8

  1. 0 TEXT$="Текст в utf8"
  2. 10 TRAP 120
  3. 20 OPEN #1,"file:///c:/other/utf.txt","output"
  4. 30 LEN%=LEN(TEXT$)
  5. 40 FOR I%=1 TO LEN%
  6. 50 C%=ASC(MID$(TEXT$,I%,1))
  7. 60 IF NOT C%=0 AND C%<128 THEN PUT #1,C%:GOTO 110
  8. 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
  9. 80 PUT #1,224 BITOR (15 BITAND (C%/4096))
  10. 90 PUT #1,128 BITOR (63 BITAND (C%/64))
  11. 100 PUT #1,128 BITOR (63 BITAND C%)
  12. 110 NEXT I%
  13. 120 CLOSE #1:PRINT "ok"

Реклама

Мы в соцсетях

tw tg yt gt