aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaksim <MoNTE48@mail.ua>2020-04-17 23:46:30 +0200
committerGitHub <noreply@github.com>2020-04-17 23:46:30 +0200
commit23c6d0c31f2e0a4a6032b0afb02fab1d5f9c517b (patch)
treeadb28d4b6d40641e03d15746fc775885de1b0eca /src
parent4e2473ec493689c3bc7d619fe17ee31c7f20945b (diff)
downloadminetest-23c6d0c31f2e0a4a6032b0afb02fab1d5f9c517b.tar.gz
minetest-23c6d0c31f2e0a4a6032b0afb02fab1d5f9c517b.tar.bz2
minetest-23c6d0c31f2e0a4a6032b0afb02fab1d5f9c517b.zip
Android: fix handling non-latin characters on older Android devices (#9309)
Diffstat (limited to 'src')
-rw-r--r--src/server.cpp8
-rw-r--r--src/util/string.cpp8
2 files changed, 16 insertions, 0 deletions
diff --git a/src/server.cpp b/src/server.cpp
index b3992b9b1..c32aa5306 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -3031,8 +3031,16 @@ std::wstring Server::handleChat(const std::string &name, const std::wstring &wna
line += L"-!- You don't have permission to shout.";
broadcast_line = false;
} else {
+ /*
+ Workaround for fixing chat on Android. Lua doesn't handle
+ the Cyrillic alphabet and some characters on older Android devices
+ */
+#ifdef __ANDROID__
+ line += L"<" + wname + L"> " + wmessage;
+#else
line += narrow_to_wide(m_script->formatChatMessage(name,
wide_to_narrow(wmessage)));
+#endif
}
/*
diff --git a/src/util/string.cpp b/src/util/string.cpp
index e6c52585d..2ee3ec735 100644
--- a/src/util/string.cpp
+++ b/src/util/string.cpp
@@ -209,6 +209,9 @@ wchar_t *narrow_to_wide_c(const char *str)
}
std::wstring narrow_to_wide(const std::string &mbs) {
+#ifdef __ANDROID__
+ return utf8_to_wide(mbs);
+#else
size_t wcl = mbs.size();
Buffer<wchar_t> wcs(wcl + 1);
size_t len = mbstowcs(*wcs, mbs.c_str(), wcl);
@@ -216,11 +219,15 @@ std::wstring narrow_to_wide(const std::string &mbs) {
return L"<invalid multibyte string>";
wcs[len] = 0;
return *wcs;
+#endif
}
std::string wide_to_narrow(const std::wstring &wcs)
{
+#ifdef __ANDROID__
+ return wide_to_utf8(wcs);
+#else
size_t mbl = wcs.size() * 4;
SharedBuffer<char> mbs(mbl+1);
size_t len = wcstombs(*mbs, wcs.c_str(), mbl);
@@ -229,6 +236,7 @@ std::string wide_to_narrow(const std::wstring &wcs)
mbs[len] = 0;
return *mbs;
+#endif
}