X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=String.js;h=f5a603e79dc40d54767f8da2f31f422a2fc1d630;hp=e7272dc9a8552204ebfe0ab9495f7b99af263f96;hb=refs%2Fheads%2Fwip_alan_T6102_issue_with_word_clean;hpb=c690a62a23e263d4b129c94f963cd81d3710def8 diff --git a/String.js b/String.js index e7272dc9a8..f5a603e79d 100644 --- a/String.js +++ b/String.js @@ -66,22 +66,6 @@ var s = String.format('
{1}
', cls, text); return format.replace(/\{(\d+)\}/g, function(m, i){ return Roo.util.Format.htmlEncode(args[i]); }); - }. - - function unicodeClean() { - return this.replace(/[\s\S]/g, - function(character) { - if (character.charCodeAt()< 256) { - return character; - } - try { - encodeURIComponent(character); - } catch(e) { - return ''; - } - return character; - } - ); } @@ -106,4 +90,27 @@ sort = (sort == 'ASC' ? 'DESC' : 'ASC'); String.prototype.toggle = function(value, other){ return this == value ? other : value; -}; \ No newline at end of file +}; + + +/** + * 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; + } + ); +}; +