- Source:
Methods
-
<static> decode(data) → {string}
-
Decodes encoded ASCII back to UTF-8.
Parameters:
Name Type Description data
string An ASCII string - Source:
Returns:
A (potentially) UTF-8 String- Type
- string
Example
var ascii_string = "ÅÄ©ÅĿŶ ÇÆÈÊÊÉε"; // it's really ASCII, trust me. convert.utf8.decode(ascii_string); // Unicode output: "ŞĩŁĿŶ ǙƝȈʗʘɗε"
-
<static> encode(data) → {string}
-
Encodes UTF8 Unicode data to ASCII.
Parameters:
Name Type Description data
string A non-ASCII string - Source:
Returns:
An ASCII string- Type
- string
Example
var unicode_string = "ŞĩŁĿŶ ǙƝȈʗʘɗε"; convert.utf8.encode(unicode_string); // ASCII output: "ÅÄ©ÅĿŶ ÇÆÈÊÊÉε"
-
<static> is_utf8_string(str) → {boolean}
-
Checks to see if a string has UTF8 characters. (We check for character codes that are multi-byte integer values > 255)
Parameters:
Name Type Description str
string A string, maybe containing UTF8 characters - Source:
Returns:
True if UTF8 characters are found- Type
- boolean
Example
convert.utf8.is_utf8_string("ŞĩŁĿŶ ǙƝȈʗʘɗε"); // returns true