NETWORKING: Convert translation results to UTF-8 for local webserver pages
This commit is contained in:
parent
c38600410e
commit
caf0968078
11 changed files with 82 additions and 64 deletions
|
@ -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
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue