mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Fix behavior of non-ASCII bytes with INCHARMAP (#1308)
This commit is contained in:
@@ -180,7 +180,7 @@ bool charmap_HasChar(char const *input)
|
|||||||
struct Charnode const *node = &charmap->nodes[0];
|
struct Charnode const *node = &charmap->nodes[0];
|
||||||
|
|
||||||
for (; *input; input++) {
|
for (; *input; input++) {
|
||||||
size_t next = node->next[*input - 1];
|
size_t next = node->next[(uint8_t)*input - 1];
|
||||||
|
|
||||||
if (!next)
|
if (!next)
|
||||||
return false;
|
return false;
|
||||||
@@ -212,7 +212,7 @@ size_t charmap_ConvertNext(char const **input, uint8_t **output)
|
|||||||
size_t rewindDistance = 0;
|
size_t rewindDistance = 0;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
uint8_t c = **input - 1;
|
uint8_t c = (uint8_t)**input - 1;
|
||||||
|
|
||||||
if (**input && node->next[c]) {
|
if (**input && node->next[c]) {
|
||||||
// Consume that char
|
// Consume that char
|
||||||
|
|||||||
11
test/asm/charmap-unicode.asm
Normal file
11
test/asm/charmap-unicode.asm
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
MACRO test
|
||||||
|
charmap \1, 42
|
||||||
|
assert charlen(\1) == 1
|
||||||
|
assert incharmap(\1) == 1
|
||||||
|
ENDM
|
||||||
|
|
||||||
|
test "a" ; one ASCII
|
||||||
|
test "hi~!!1" ; many ASCII
|
||||||
|
test "デ" ; one UTF-8
|
||||||
|
test "グレイシア" ; many UTF-8
|
||||||
|
test "Pokémon" ; mixed
|
||||||
Reference in New Issue
Block a user