v1.KAWA.043
Turns out a single missing =
in the UTF-8 code messed up the save game selection list. And that inspired a mild rethinking for StrAt
... and StrCase
while I was there.
StrAt
now just assumes you're working with single-byte characters. If you want to change a character at a given position for one that needs more or fewer bytes, consider using Utf8To16
and its counterpart instead:
; Change the fifth character (zero-based!) in mbcsString from a regular o or whatever to an o-macron
; by first widening it.
(Utf8To16 @wideString @mbcsString 32) ; up to 32 characters or the first null, whichever comes first.
(= [wideString 4] $14D)
(Utf16To8 @mbcsString @wideString 32)
; mbcsString's length just went up a little.
This method should be safe to use in a build with UTF-8 disabled, as the pair will just turn bytes to shorts and back.
StrCase
now considers the current port's font to decide if it should consider UTF-8 sequences, or just go for raw bytes like a build with UTF-8 disabled would. Often that will mean font 0 decides. If it's a 128-character font, or a 256-character font in Windows-1252 order, the Unicode case mapping should work for most characters.