; DecodeText Example ; ------------------ ; Requires Extended mode. ; An old game's save file stored the player name in the legacy ; Windows-1252 code page: C a f é as the bytes 67 97 102 233 bank=CreateBank(4) PokeByte bank,0,67 PokeByte bank,1,97 PokeByte bank,2,102 PokeByte bank,3,233 Print "Legacy bytes in the bank: 67 97 102 233" Print "" ; DecodeText converts a Bank range to a UTF-8 String using the ; selected strict codec - name the legacy code page explicitly name$=DecodeText(bank,0,BankSize(bank),TEXT_WINDOWS_1252) If name="" Then RuntimeError TextCodecError() Print "Decoded as Windows-1252: "+name Print "" ; Offset and count select a sub-range - just the first 3 bytes Print "First three bytes only: "+DecodeText(bank,0,3,TEXT_WINDOWS_1252) Print "" ; Note: byte 233 alone is NOT valid UTF-8, so decoding the same ; bank with the default strict UTF-8 codec would fail - always ; know which encoding legacy data really uses. FreeBank bank Print "" Print "Press any key to close the example" WaitKey End