Namespace: utf8

convert. utf8

Static class for UTF8 Encode / Decode functionality. This is a child of convert. Since most of our encryption, hashing and convert methods expect ASCII-encoded binary strings (ie. 0 <= [character code] <= 255), they will misbehave on non-ASCII characters. We can use convert.utf8.is_utf8_string to test whether we need to use convert.utf8.encode to encode to ASCII before using elsewhere.
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