micwallace / WebPrint

Print directly to printers using Javascript.
104 stars 46 forks source link

Can't Print Chinese Character or Unicode Char. #14

Open jink2005 opened 5 years ago

jink2005 commented 5 years ago

Print Chinese Character will get following error: Error: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.

Maybe need encodeURIComponent and decodeURIComponent.

jink2005 commented 5 years ago

I use Base64 lib from third party replace the btoa to solve this problem. this.printRaw = function (data, printer) { // var request = {a: "printraw", printer: printer, data: btoa(data)}; var request = {a: "printraw", printer: printer, data: BASE64.encode(data)}; sendAppletRequest(request); };