From 2be7b323a56dba483095826034ecb3c1496b2df5 Mon Sep 17 00:00:00 2001 From: Leshana Date: Sat, 14 May 2016 23:23:11 -0400 Subject: [PATCH] =?UTF-8?q?Fix=20the=20letter=20=C3=BF=20in=20nano-ui=20di?= =?UTF-8?q?splays?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Particularly noticable on the cartridge button of the PDA, any time we transmit a name containing \improper or \proper using nanoui it shows up as ÿ * This is becuase BYOND internally handles these escapes by simply using character 0xFF etc. * We'd better strip them out before sending them as JSON data so they aren't rendered as ÿ when treated as utf-8 encoding. --- code/_helpers/text.dm | 7 +++++++ code/modules/nano/nanoui.dm | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/code/_helpers/text.dm b/code/_helpers/text.dm index be836248a6c..68cb5276fad 100644 --- a/code/_helpers/text.dm +++ b/code/_helpers/text.dm @@ -324,4 +324,11 @@ proc/TextPreview(var/string,var/len=40) return 1 return 0 +/** + * Strip out the special beyond characters for \proper and \improper + * from text that will be sent to the browser. + */ +/proc/strip_improper(var/text) + return replacetext(replacetext(text, "\proper", ""), "\improper", "") + #define gender2text(gender) capitalize(gender) \ No newline at end of file diff --git a/code/modules/nano/nanoui.dm b/code/modules/nano/nanoui.dm index e270185414b..29a2623984c 100644 --- a/code/modules/nano/nanoui.dm +++ b/code/modules/nano/nanoui.dm @@ -345,10 +345,11 @@ nanoui is used to open and update nano browser uis var/template_data_json = "{}" // An empty JSON object if (templates.len > 0) - template_data_json = json_encode(templates) + template_data_json = strip_improper(json_encode(templates)) var/list/send_data = get_send_data(initial_data) var/initial_data_json = replacetext(replacetext(json_encode(send_data), """, "&#34;"), "'", "'") + initial_data_json = strip_improper(initial_data_json); var/url_parameters_json = json_encode(list("src" = "\ref[src]")) @@ -459,7 +460,7 @@ nanoui is used to open and update nano browser uis var/list/send_data = get_send_data(data) //user << list2json(data) // used for debugging - user << output(list2params(list(json_encode(send_data))),"[window_id].browser:receiveUpdateData") + user << output(list2params(list(strip_improper(json_encode(send_data)))),"[window_id].browser:receiveUpdateData") /** * This Topic() proc is called whenever a user clicks on a link within a Nano UI