Class

Charset

Charset(optionsopt)

Create a new character set info instance. Charset instances give information about a particular character set, such as whether or not it is single byte or multibyte, and which languages commonly use that charset.

The optional options object holds extra parameters if they are necessary. The current list of supported options are:

  • name - the name of the charset. This can be given as any commonly used name for the character set, which is normalized to a standard IANA name before its info is loaded. If a name is not given, this class will return information about the base character set of Javascript, which is currently Unicode as encoded in UTF-16.
  • onLoad - a callback function to call when this object is fully loaded. When the onLoad option is given, this class will attempt to load any missing data using the ilib loader callback. When the constructor is done (even if the data is already preassembled), the onLoad function is called with the current instance as a parameter, so this callback can be used with preassembled or dynamic loading or a mix of the two.
  • sync - tell whether to load any missing data synchronously or asynchronously. If this option is given as "false", then the "onLoad" callback must be given, because the instance returned from this constructor will not be usable for a while.
  • loadParams - an object containing parameters to pass to the loader callback function when data is missing. The parameters are not interpretted or modified in any way. They are simply passed along. The object may contain any property/value pairs as long as the calling code is in agreement with the loader callback function as to what those parameters mean.

If this copy of ilib is pre-assembled and all the data is already available, or if the data was already previously loaded, then this constructor will call the onLoad callback immediately when the initialization is done. If the onLoad option is not given, this class will only attempt to load any missing data synchronously.

Constructor

# new Charset(optionsopt)

Parameters:
Name Type Attributes Description
options Object <optional>

options which govern the construction of this instance

See:
  • ilib#setLoaderCallback for information about registering a loader callback instance

View Source Charset.js, line 70

Methods

# getDescription() → {string}

Return a short description of the character set.

View Source Charset.js, line 164

a description of the character set

string

# getMaxCharWidth() → {number}

Return the largest number of bytes that a single character in this charset could use.

View Source Charset.js, line 185

the largest number of bytes that a single character in this charset uses

number

# getMinCharWidth() → {number}

Return the smallest number of bytes that a single character in this charset could use. For most charsets, this is 1, but for some charsets such as Unicode encoded in UTF-16, this may be 2 or more.

View Source Charset.js, line 175

the smallest number of bytes that a single character in this charset uses

number

# getName() → {string}

Return the standard normalized name of this charset. The list of standard names comes from the IANA registry of character set names at http://www.iana.org/assignments/character-sets/character-sets.xhtml.

View Source Charset.js, line 145

the name of the charset

string

# getOriginalName() → {string}

Return the original name that this instance was constructed with before it was normalized to the standard name returned by #getName.

View Source Charset.js, line 155

the original name that this instance was constructed with

string

# getScripts() → {Array.<string>}

Return an array of ISO script codes whose characters can be encoded with this character set.

View Source Charset.js, line 218

an array of ISO script codes supported by this charset

Array.<string>

# isBigEndian() → {boolean}

Return whether or not characters larger than 1 byte use the big endian order or little endian.

View Source Charset.js, line 208

true if this character set uses big endian order, or false otherwise

boolean

# isMultibyte() → {boolean}

Return true if this is a multibyte character set, or false for a fixed width character set. A multibyte character set is one in which the characters have a variable width. That is, one character may use 1 byte and a different character might use 2 or 3 bytes.

View Source Charset.js, line 197

true if this is a multibyte charset, or false otherwise

boolean