summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjussi2024-01-30 13:36:23 +0200
committerjussi2024-01-30 13:36:23 +0200
commitd21512d88c2e24cf8cb230d29fb253fb5efd1661 (patch)
tree87b62953f4996344d68b93bd8228fc67f07be77d /src
parent143453af9ea9be82b2d58d665bed62abb716e21f (diff)
downloadreilua-enhanced-d21512d88c2e24cf8cb230d29fb253fb5efd1661.tar.gz
reilua-enhanced-d21512d88c2e24cf8cb230d29fb253fb5efd1661.tar.bz2
reilua-enhanced-d21512d88c2e24cf8cb230d29fb253fb5efd1661.zip
Rune lib and __concat for variable libs.
Diffstat (limited to 'src')
-rw-r--r--src/text.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/text.c b/src/text.c
index e214c70..8981a9a 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1120,20 +1120,23 @@ int ltextGetCodepointPrevious( lua_State *L ) {
}
/*
-> string, utf8Size = RL.CodepointToUTF8( int codepoint )
+> string = RL.CodepointToUTF8( int codepoint )
Encode one codepoint into UTF-8 byte array
-- Success return string, int
+- Success return string
*/
int ltextCodepointToUTF8( lua_State *L ) {
int codepoint = luaL_checkinteger( L, 1 );
int utf8Size = 0;
- lua_pushstring( L, CodepointToUTF8( codepoint, &utf8Size ) );
- lua_pushinteger( L, utf8Size );
+ char text[5] = { '\0' };
+ const char* utf8 = CodepointToUTF8( codepoint, &utf8Size );
+ memcpy( text, utf8, utf8Size );
- return 2;
+ lua_pushstring( L, text );
+
+ return 1;
}
/*
@@ -1155,7 +1158,7 @@ int ltextTextInsert( lua_State *L ) {
// char* result = TextInsert( text, insert, position ); // Bug in the raylib implementation.
int textLen = TextLength( text );
- int insertLen = TextLength( insert );
+ int insertLen = TextLength( insert );
char* result = RL_MALLOC( textLen + insertLen + 1 );
memcpy( result, text, position );