From 5186d1d4f6c0fd866ef45046ac8368f5ab5693ae Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 31 Jul 2009 23:13:53 +0000 Subject: (svn r17013) -Fix [FS#3074]: concatenating strings in Squirrel when non-ASCII strings were received from OpenTTD failed. The number of bytes in an UTF-8 encoded string isn't always the same as the number of characters in the decoded (into wchars) string --- src/script/squirrel_helper.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/script') diff --git a/src/script/squirrel_helper.hpp b/src/script/squirrel_helper.hpp index ba4069d74..580f49cbd 100644 --- a/src/script/squirrel_helper.hpp +++ b/src/script/squirrel_helper.hpp @@ -80,8 +80,8 @@ namespace SQConvert { template <> inline int Return (HSQUIRRELVM vm, int64 res) { sq_pushinteger(vm, ClampToI32(res)); return 1; } template <> inline int Return (HSQUIRRELVM vm, Money res) { sq_pushinteger(vm, ClampToI32(res)); return 1; } template <> inline int Return (HSQUIRRELVM vm, bool res) { sq_pushbool (vm, res); return 1; } - template <> inline int Return (HSQUIRRELVM vm, char *res) { if (res == NULL) sq_pushnull(vm); else {sq_pushstring (vm, OTTD2FS(res), strlen(res)); free(res);} return 1; } - template <> inline int Return(HSQUIRRELVM vm, const char *res) { if (res == NULL) sq_pushnull(vm); else {sq_pushstring (vm, OTTD2FS(res), strlen(res));} return 1; } + template <> inline int Return (HSQUIRRELVM vm, char *res) { if (res == NULL) sq_pushnull(vm); else { sq_pushstring(vm, OTTD2FS(res), -1); free(res); } return 1; } + template <> inline int Return(HSQUIRRELVM vm, const char *res) { if (res == NULL) sq_pushnull(vm); else { sq_pushstring(vm, OTTD2FS(res), -1); } return 1; } template <> inline int Return (HSQUIRRELVM vm, void *res) { sq_pushuserpointer(vm, res); return 1; } /** -- cgit v1.2.3-70-g09d2