From: Jay Freeman (saurik) Date: Wed, 26 Dec 2012 15:43:09 +0000 (+0000) Subject: Export a Unicode class as replacement for string. X-Git-Url: https://git.saurik.com/utf16js.git/commitdiff_plain/8317d54a75057c75ad4cfb15649cb0ebc0fa12da?ds=sidebyside Export a Unicode class as replacement for string. --- diff --git a/utf16.js b/utf16.js index 3aea691..9c06cdd 100644 --- a/utf16.js +++ b/utf16.js @@ -106,6 +106,27 @@ var substring = function(string, start, stop) { 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, @@ -117,6 +138,8 @@ return { length: length, substr: substr, substring: substring, + + Unicode: Unicode, }; });