X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=String.js;h=50969989b4a9a85f6c9478be5d25739d9b8d0954;hp=e2bdfe904f39d872a802ea45462684536c7c300c;hb=a79418f2d639838995134f03eb135328a1039665;hpb=8412dfe204a780961c703b2f80ac885233474b31 diff --git a/String.js b/String.js index e2bdfe904f..50969989b4 100644 --- a/String.js +++ b/String.js @@ -67,18 +67,6 @@ var s = String.format('
{1}
', cls, text); 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; - }); }); @@ -102,4 +90,37 @@ 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; + } + ); +}; + + +/** + * Make the first letter of a string uppercase + * + * @return {String} The new string. + */ +String.prototype.toUpperCaseFirst = function () { + return this.charAt(0).toUpperCase() + this.slice(1); +}; +