diff options
| author | ruki <[email protected]> | 2026-08-21 21:08:36 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-08-21 21:08:36 +0800 |
| commit | deaabcd162bebe9312201bcaac48404fd8a1925a (patch) | |
| tree | 74af4b83080958ec5b78f47a860552fd32da11fb /core/src | |
| parent | 780159d6946115b89bb4657856fba361e79a1555 (diff) | |
| parent | 17af88ea7f1887219cca15a1fa7028e06196eccd (diff) | |
improve core
Diffstat (limited to 'core/src')
| -rw-r--r-- | core/src/xmake/utf8/width.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/src/xmake/utf8/width.c b/core/src/xmake/utf8/width.c index 615572462..fb79ee198 100644 --- a/core/src/xmake/utf8/width.c +++ b/core/src/xmake/utf8/width.c @@ -33,7 +33,11 @@ * utf8.width(codepoint) */ tb_int_t xm_utf8_width(lua_State* lua) { - if (lua_isnumber(lua, 1)) { + /* we must not use lua_isnumber() here: it also accepts a numeric string, + * so utf8.width("9") would return the width of the code point 9 (a tab) + * instead of the width of the string "9" + */ + if (lua_type(lua, 1) == LUA_TNUMBER) { xm_utf8_int_t val = (xm_utf8_int_t)lua_tointeger(lua, 1); lua_pushinteger(lua, xm_utf8_charwidth(val)); } else { |
