BACKENDS: CLIPBOARD: Improve usage for SDL & Android.

- Fix possible issue for setting text inside clipboard for SDL.
- Always return a decoded string when from UTF-8 in Android when fetch clipboard.
This commit is contained in:
aryanrawlani28 2020-08-21 11:19:25 +05:30 committed by Eugene Sandulenko
parent d41d0e9b22
commit 29b6274e67
2 changed files with 6 additions and 9 deletions

View File

@ -300,11 +300,7 @@ Common::U32String JNI::getTextFromClipboard() {
Common::String text = convertFromJString(env, javaText, "UTF-8");
env->DeleteLocalRef(javaText);
if (getCurrentCharset() == "UTF-32") {
return text.decode();
}
return Common::U32String(text);
return text.decode();
}
bool JNI::setTextInClipboard(const Common::U32String &text) {

View File

@ -508,14 +508,15 @@ Common::U32String OSystem_SDL::getTextFromClipboard() {
}
bool OSystem_SDL::setTextInClipboard(const Common::U32String &text) {
// The encoding we need to use is UTF-8. Assume we currently have the
// current TranslationManager encoding or ISO-8859-1.
char *utf8_text = (char *)text.encode().c_str();
// The encoding we need to use is UTF-8.
Common::String textStr = text.encode();
char *utf8_text = (char *)textStr.c_str();
if (utf8_text) {
int status = SDL_SetClipboardText(utf8_text);
return status == 0;
}
return SDL_SetClipboardText(text.encode().c_str()) == 0;
return SDL_SetClipboardText(textStr.c_str()) == 0;
}
#endif