]> git.saurik.com Git - utf16js.git/commitdiff
Export a Unicode class as replacement for string.
authorJay Freeman (saurik) <saurik@saurik.com>
Wed, 26 Dec 2012 15:43:09 +0000 (15:43 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Wed, 26 Dec 2012 15:43:09 +0000 (15:43 +0000)
utf16.js

index 3aea6915e596140fdde4616a2ff227223ce73847..9c06cdd03423d566e471eb1d854efac0703f4933 100644 (file)
--- a/utf16.js
+++ b/utf16.js
@@ -106,6 +106,27 @@ var substring = function(string, start, stop) {
     return string.substring(range[0], range[1]);
 };
 
     return string.substring(range[0], range[1]);
 };
 
+var Unicode = function(string) {
+    this.string = string;
+    this.length = length(string);
+};
+
+Unicode.prototype.charAt = function(index) {
+    return new Unicode(charAt(this.string, index));
+};
+
+Unicode.prototype.substr = function(start, length) {
+    return new Unicode(substr(this.string, start, length));
+};
+
+Unicode.prototype.substring = function(start, end) {
+    return new Unicode(substring(this.string, start, end));
+};
+
+Unicode.prototype.toString = function() {
+    return this.string;
+};
+
 return {
     decode: decode,
     encode: encode,
 return {
     decode: decode,
     encode: encode,
@@ -117,6 +138,8 @@ return {
     length: length,
     substr: substr,
     substring: substring,
     length: length,
     substr: substr,
     substring: substring,
+
+    Unicode: Unicode,
 };
 
 });
 };
 
 });