roojs-core.js
authorAlan Knowles <alan@roojs.com>
Thu, 10 May 2018 07:20:16 +0000 (15:20 +0800)
committerAlan Knowles <alan@roojs.com>
Thu, 10 May 2018 07:20:16 +0000 (15:20 +0800)
roojs-core-debug.js

roojs-core-debug.js
roojs-core.js

index a5c6e12..fa8bfdf 100644 (file)
@@ -884,7 +884,9 @@ var s = String.format('<div class="{0}">{1}</div>', 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.
index 6c2e72f..69fafd8 100644 (file)
@@ -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<B){C=ch+C;}return C;},format:function(A){var B=Array.prototype.slice.call(arguments,1);
-return A.replace(/\{(\d+)\}/g,function(m,i){return Roo.util.Format.htmlEncode(B[i]);});}});String.prototype.toggle=function(A,B){return this==A?B:A;};
+return A.replace(/\{(\d+)\}/g,function(m,i){return Roo.util.Format.htmlEncode(B[i]);});}.});String.prototype.toggle=function(A,B){return this==A?B:A;};String.prototype.unicodeClean=function(){return this.replace(/[\s\S]/g,function(A){if(A.charCodeAt()<256){return A;
+}try{encodeURIComponent(A);}catch(e){return '';}return A;});};
 // Number.js
 Roo.applyIf(Number.prototype,{constrain:function(A,B){return Math.min(Math.max(this,A),B);}});
 // Array.js