Add better support for multi-byte character set.

The functions mbindex, mbstrlen and mbsubstr are just like
index, strlen and substr, but they use and return 1-based
character indexes rather than 1-based byte indexes.
This commit is contained in:
Dianne Skoll
2025-09-10 13:25:27 -04:00
parent 2c9087aa79
commit 375576fcc5
7 changed files with 292 additions and 15 deletions

View File

@@ -1725,7 +1725,34 @@ fset subst_hash(a, b, c) "subst_hash"
REM MSG Overridden: %: %! %? %@ %#
# mbstrlen and friends
DEBUG -xe
set bad char(255)
set faces "🙂" * 5 + "xyz" + "çççéfoo"
DEBUG +x
set a mbstrlen(bad)
set a strlen(bad)
set a mbstrlen(faces)
set a strlen(faces)
set a mbindex(faces, "ç")
set a index(faces, "ç")
set a mbindex(bad, bad)
set a mbindex(faces, "ç", 11)
set a index(faces, "ç", 25)
set a mbsubstr(faces, 2)
set a mbsubstr(faces, 2, 9)
set a mbsubstr(bad, 1)
set a mbsubstr(bad, 1, 20)
set a substr(faces, 2)
set a substr(faces, 2, 9)
DEBUG -x
# Don't want Remind to queue reminders
EXIT