aboutsummaryrefslogtreecommitdiff
path: root/backends/networking/sdl_net/handlerutils.cpp
diff options
context:
space:
mode:
authorThierry Crozat2019-09-19 00:16:24 +0100
committerFilippos Karapetis2019-09-21 22:15:26 +0300
commitcaf096807895d30983c649e4218033fa3abccbfa (patch)
treee030f70fe98f7d0a7cac420f7587d19781f8dbdb /backends/networking/sdl_net/handlerutils.cpp
parentc38600410e7ea5cf0bbb4edf11ccafa49f332f05 (diff)
downloadscummvm-rg350-caf096807895d30983c649e4218033fa3abccbfa.tar.gz
scummvm-rg350-caf096807895d30983c649e4218033fa3abccbfa.tar.bz2
scummvm-rg350-caf096807895d30983c649e4218033fa3abccbfa.zip
NETWORKING: Convert translation results to UTF-8 for local webserver pages
Diffstat (limited to 'backends/networking/sdl_net/handlerutils.cpp')
-rw-r--r--backends/networking/sdl_net/handlerutils.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/backends/networking/sdl_net/handlerutils.cpp b/backends/networking/sdl_net/handlerutils.cpp
index 73ddf9e83f..36f615f93b 100644
--- a/backends/networking/sdl_net/handlerutils.cpp
+++ b/backends/networking/sdl_net/handlerutils.cpp
@@ -28,6 +28,7 @@
#include "common/file.h"
#include "common/translation.h"
#include "common/unzip.h"
+#include "common/encoding.h"
namespace Networking {
@@ -171,8 +172,23 @@ bool HandlerUtils::permittedPath(const Common::String path) {
return hasPermittedPrefix(path) && !isBlacklisted(path);
}
+Common::String HandlerUtils::toUtf8(const char *text) {
+#ifdef USE_TRANSLATION
+ Common::String guiEncoding = TransMan.getCurrentCharset();
+ if (guiEncoding != "ASCII") {
+ char *utf8Text = Common::Encoding::convert("utf-8", guiEncoding, text, strlen(text));
+ if (utf8Text != nullptr) {
+ Common::String str(utf8Text);
+ delete [] utf8Text;
+ return str;
+ }
+ }
+#endif
+ return Common::String(text);
+}
+
void HandlerUtils::setMessageHandler(Client &client, Common::String message, Common::String redirectTo) {
- Common::String response = "<html><head><title>ScummVM</title></head><body>{message}</body></html>";
+ Common::String response = "<html><head><title>ScummVM</title><meta charset=\"utf-8\"/></head><body>{message}</body></html>";
// load stylish response page from the archive
Common::SeekableReadStream *const stream = getArchiveFile(INDEX_PAGE_NAME);
@@ -194,7 +210,7 @@ void HandlerUtils::setFilesManagerErrorMessageHandler(Client &client, Common::St
message.c_str(),
client.queryParameter("ajax") == "true" ? "AJAX" : "",
"%2F", //that's encoded "/"
- _("Back to the files manager")
+ toUtf8(_("Back to the files manager")).c_str()
),
redirectTo
);