From 0ad4dd6d7f856dbc5ccf6bce5f3ab74d13898396 Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Tue, 6 Nov 2012 16:32:23 -0500 Subject: [PATCH] Fix foreign character display in receipts This commit makes two changes to the staff client print code to help with the proper display of foreign characters: 1) Specify the utf-8 charset in the receipt Data URIs. 2) Properly encode the entire data string using encodeURIComponent rather than encode(). Failing to do so was causing XULRunner to be "creative" with the interpretation of the data. Signed-off-by: Dan Wells Signed-off-by: Ben Shum --- Open-ILS/xul/staff_client/chrome/content/util/print.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/util/print.js b/Open-ILS/xul/staff_client/chrome/content/util/print.js index 45cd623bba..61672ec5cf 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/print.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/print.js @@ -175,13 +175,14 @@ util.print.prototype = { my_prefix = xulG.url_prefix(my_prefix); } } - var print_url = 'data:text/html,' + var print_url = '' + '' + ''; if(this.data.hash.aous['print.custom_js_file']) { print_url += ''; } - print_url += '' + window.escape(msg.replace(/]*>.*?<\/script>/gi,'')) + ''; + print_url += '' + msg.replace(/]*>.*?<\/script>/gi,'') + ''; + print_url = 'data:text/html;charset=utf-8,' + encodeURIComponent(print_url); obj.win.openDialog(print_url,'receipt_temp','chrome,resizable,modal', { "data" : params.data, "list" : params.list}, function(w) { try { obj.NSPrint(w, silent, params); @@ -295,8 +296,8 @@ util.print.prototype = { s=s.replace(/onload\s*=\s*'[^']*'/gi,''); if (params.sample_frame) { - var jsrc = 'data:text/javascript,' + window.escape('var params = { "data" : ' + js2JSON(params.data) + ', "list" : ' + js2JSON(params.list) + '};'); - params.sample_frame.setAttribute('src','data:text/html,' + window.escape(s) + ''); + var jsrc = 'data:text/javascript,' + encodeURIComponent('var params = { "data" : ' + js2JSON(params.data) + ', "list" : ' + js2JSON(params.list) + '};'); + params.sample_frame.setAttribute('src','data:text/html;charset=utf-8,' + encodeURIComponent('' + s + '')); } else { this.simple(s,params); } -- 2.11.0