X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=String.js;h=50969989b4a9a85f6c9478be5d25739d9b8d0954;hb=b999dac6d220ed742af894af4750d19d0e6dc586;hp=d53325392c9827679378c59e2430010a00ffea3f;hpb=4d9cd83949f3c24871af08cebb30b1f8102ac4c9;p=roojs1
diff --git a/String.js b/String.js
index d53325392c..50969989b4 100644
--- a/String.js
+++ b/String.js
@@ -67,6 +67,8 @@ var s = String.format('
{1}
', cls, text);
return Roo.util.Format.htmlEncode(args[i]);
});
}
+
+
});
/**
@@ -88,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);
+};
+