From b379d503514258d73479d8950753d67acf054d79 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Tue, 18 Feb 2014 13:25:03 +0100 Subject: [PATCH] Decode and encode array directly without for loop --- js/weechat.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/js/weechat.js b/js/weechat.js index a66d7b7..0b220b1 100644 --- a/js/weechat.js +++ b/js/weechat.js @@ -572,13 +572,12 @@ * @return Decoded string */ WeeChatProtocol._uia2s = function(uia) { - var str = []; + if(!uia.length || uia[0] === 0) return ""; - for (var c = 0; c < uia.length && uia[c] !== 0; c++) { - str.push(String.fromCharCode(uia[c])); - } + var encodedString = String.fromCharCode.apply(null, uia), + decodedString = decodeURIComponent(escape(encodedString)); - return decodeURIComponent(escape(str.join(''))); + return decodedString; }; /**