mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Added Lua 5.3's UTF-8 module to LÖVE. Resolves issue #951.
The module must be required before use, i.e. utf8 = require("utf8"). API documentation can be found here: http://www.lua.org/manual/5.3/manual.html#6.5
Removing the last unicode character in a string (for proper backspace support in text boxes, for example) can be done using utf8.offset, e.g. text = text:sub(1, utf8.offset(text, -1) - 1).
This commit is contained in:
@@ -43,6 +43,9 @@
|
||||
#ifdef LOVE_ENABLE_ENET
|
||||
# include "libraries/enet/lua-enet.h"
|
||||
#endif
|
||||
#ifdef LOVE_ENABLE_LUAUTF8
|
||||
# include "libraries/luautf8/lutf8lib.h"
|
||||
#endif
|
||||
|
||||
// Scripts
|
||||
#include "scripts/boot.lua.h"
|
||||
@@ -228,9 +231,7 @@ int luaopen_love(lua_State * L)
|
||||
|
||||
// Preload module loaders.
|
||||
for (int i = 0; modules[i].name != 0; i++)
|
||||
{
|
||||
love::luax_preload(L, modules[i].func, modules[i].name);
|
||||
}
|
||||
|
||||
#ifdef LOVE_ENABLE_LUASOCKET
|
||||
love::luasocket::__open(L);
|
||||
@@ -238,6 +239,9 @@ int luaopen_love(lua_State * L)
|
||||
#ifdef LOVE_ENABLE_ENET
|
||||
love::luax_preload(L, luaopen_enet, "enet");
|
||||
#endif
|
||||
#ifdef LOVE_ENABLE_LUAUTF8
|
||||
love::luax_preload(L, luaopen_luautf8, "utf8");
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user