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
}
/*
}
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);
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);
mbs[len] = 0;
return *mbs;
+#endif
}