From 4dd8460f6a45d7956455ef9b39b33126c1b40e15 Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Wed, 3 Dec 2014 22:02:34 -0500 Subject: fix arrows and printing backslashes --- js/matrix.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'js/matrix.js') diff --git a/js/matrix.js b/js/matrix.js index 98c132d..9809865 100644 --- a/js/matrix.js +++ b/js/matrix.js @@ -122,7 +122,7 @@ Matrix.prototype.mirc = function () { Matrix.prototype.irssi = function(){ var txt = this.mirc() .replace(/\%/g, '%%') - .replace(/\\/g, '\\\\') + .replace(/\\/g, '\\x5C') .replace(/\"/g, '\\\"') .replace(/\'/g, '\\\'') .replace(/\`/g, '\\\`') @@ -130,9 +130,29 @@ Matrix.prototype.irssi = function(){ .replace(/\s+$/g, '\n') .replace(/^\n+/, '') .replace(/\n/g, '\\n') - .replace(/\x03/g, '\\x03'); + .replace(/\x02/g, '\\x02') + .replace(/\x03/g, '\\x03') +console.log(txt.length) + var escaped_txt = "", kode + for (var i = 0; i < txt.length; i++) { + kode = txt.charCodeAt(i) + if (kode > 0x7f) { + kode = kode.toString(16) + switch (kode.length) { + case 2: + kode = "0" + kode + case 3: + kode = "0" + kode + } + escaped_txt += "\\u" + kode + } + else { + escaped_txt += txt[i] + } + } + // .replace(/\x03/g, '\\x03'); // console.log(txt) - return '/exec -out printf "' + txt + '"\n' + return '/exec -out printf "' + escaped_txt + '"\n' } Matrix.prototype.expand = function(i){ var w = this.w = clamp(this.w+i, 1, 9), h = this.h = clamp(this.h+i, 1, 9) -- cgit v1.2.3-70-g09d2