; TextCodecError Example
; ----------------------

; A player picked a name in Chinese - fine in UTF-8, but our
; legacy export format uses the Windows-1252 code page
name$="世界"
Print "Exporting player name: "+name
Print ""

; The strict codec refuses a lossy conversion instead of
; silently writing '?' characters - it returns 0
bank=EncodeText(name,TEXT_WINDOWS_1252)
Print "EncodeText(...,TEXT_WINDOWS_1252) returned "+bank+" (0 = failed)"
Print ""

; TextCodecError explains the recoverable codec failure
Print "TextCodecError:"
Print "  "+TextCodecError()
Print ""

; The same name encodes fine as UTF-8
utf8_bank=EncodeText(name,TEXT_UTF8)
Print "As UTF-8 it works: "+BankSize(utf8_bank)+" bytes"
FreeBank utf8_bank

Print ""
Print "Press any key to close the example"
WaitKey

End
