diff options
author | William Wilgus <me.theuser@yahoo.com> | 2018-10-30 22:40:23 -0400 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2018-11-01 16:34:02 +0100 |
commit | be7a58c33155e0f72ad7b1fb23cf931d085e12cb (patch) | |
tree | 201356811efb70aed3199194fbb4e61a599b2ff3 /apps/plugins/lua/rocklib.c | |
parent | bbfe4778114c76e23e9c391225da2d6f74812735 (diff) | |
download | rockbox-be7a58c33155e0f72ad7b1fb23cf931d085e12cb.tar.gz rockbox-be7a58c33155e0f72ad7b1fb23cf931d085e12cb.zip |
Lua Fix utf8encode, remove utf16 functions
The auto generated utf8/16 encode/decode functions did not work.
Upon implementing them correctly I found that lua handles the utf-8
form properly but I could not get utf-16 to work without crashing
maybe someone can come along later and implement utf-16 safe string
functions but for now utf-16 is removed.
Change-Id: I97a044e200dc27f683a45487cd93fce667c670c4
Diffstat (limited to 'apps/plugins/lua/rocklib.c')
-rw-r--r-- | apps/plugins/lua/rocklib.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index 54c2bc0c03..ed625ca369 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c | |||
@@ -472,6 +472,16 @@ RB_WRAP(create_numbered_filename) | |||
472 | return 1; | 472 | return 1; |
473 | } | 473 | } |
474 | 474 | ||
475 | RB_WRAP(utf8encode) | ||
476 | { | ||
477 | unsigned long ucs = (unsigned long) luaL_checkint(L, 1); | ||
478 | unsigned char tmp[9]; | ||
479 | unsigned char *end = rb->utf8encode(ucs, tmp); | ||
480 | *end = '\0'; | ||
481 | lua_pushstring(L, tmp); | ||
482 | return 1; | ||
483 | } | ||
484 | |||
475 | #define RB_FUNC(func) {#func, rock_##func} | 485 | #define RB_FUNC(func) {#func, rock_##func} |
476 | static const luaL_Reg rocklib[] = | 486 | static const luaL_Reg rocklib[] = |
477 | { | 487 | { |
@@ -520,6 +530,9 @@ static const luaL_Reg rocklib[] = | |||
520 | #if CONFIG_CODEC == SWCODEC | 530 | #if CONFIG_CODEC == SWCODEC |
521 | RB_FUNC(pcm), | 531 | RB_FUNC(pcm), |
522 | #endif | 532 | #endif |
533 | |||
534 | RB_FUNC(utf8encode), | ||
535 | |||
523 | {NULL, NULL} | 536 | {NULL, NULL} |
524 | }; | 537 | }; |
525 | #undef RB_FUNC | 538 | #undef RB_FUNC |