summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorruki <[email protected]>2026-08-21 21:08:36 +0800
committerGitHub <[email protected]>2026-08-21 21:08:36 +0800
commitdeaabcd162bebe9312201bcaac48404fd8a1925a (patch)
tree74af4b83080958ec5b78f47a860552fd32da11fb /core
parent780159d6946115b89bb4657856fba361e79a1555 (diff)
parent17af88ea7f1887219cca15a1fa7028e06196eccd (diff)
Merge pull request #7722 from xmake-io/coreHEADdev
improve core
Diffstat (limited to 'core')
-rw-r--r--core/src/xmake/utf8/width.c6
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 {