From a75bc8ac4aebd96fca8faece12434f4253cabaa6 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 10 May 2018 15:20:16 +0800 Subject: [PATCH] roojs-core.js roojs-core-debug.js --- roojs-core-debug.js | 30 ++++++++++++++++++++++++++++-- roojs-core.js | 3 ++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/roojs-core-debug.js b/roojs-core-debug.js index a5c6e12271..fa8bfdf781 100644 --- a/roojs-core-debug.js +++ b/roojs-core-debug.js @@ -884,7 +884,9 @@ var s = String.format('
{1}
', cls, text); return format.replace(/\{(\d+)\}/g, function(m, i){ return Roo.util.Format.htmlEncode(args[i]); }); - } + }. + + }); /** @@ -906,7 +908,31 @@ sort = (sort == 'ASC' ? 'DESC' : 'ASC'); String.prototype.toggle = function(value, other){ return this == value ? other : value; -};/* +}; + + +/** + * Remove invalid unicode characters from a string + * + * @return {String} The clean string + */ +String.prototype.unicodeClean = function () { + return this.replace(/[\s\S]/g, + function(character) { + if (character.charCodeAt()< 256) { + return character; + } + try { + encodeURIComponent(character); + } catch(e) { + return ''; + } + return character; + } + ); +}; + +/* * Based on: * Ext JS Library 1.1.1 * Copyright(c) 2006-2007, Ext JS, LLC. diff --git a/roojs-core.js b/roojs-core.js index 6c2e72f079..69fafd8a41 100644 --- a/roojs-core.js +++ b/roojs-core.js @@ -27,7 +27,8 @@ E=E.concat(B);}else if(typeof C=="number"){E=Array.prototype.slice.call(argument }var C=this;return function(){A.target=this;A.method=C;if(A.apply(B||this||window,arguments)===false){return;}return C.apply(this||window,arguments);};}}); // String.js Roo.applyIf(String,{escape:function(A){return A.replace(/('|\\)/g,"\\$1");},leftPad:function(A,B,ch){var C=new String(A);if(ch===null||ch===undefined||ch===''){ch=" ";}while(C.length