Class Charset
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.
Defined in: Charset.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Charset(options)
|
Method Attributes | Method Name and Description |
---|---|
Return a short description of the character set.
|
|
Return the largest number of bytes that a single character in this charset
could use.
|
|
Return the smallest number of bytes that a single character in this charset
could use.
|
|
getName()
Return the standard normalized name of this charset.
|
|
Return the original name that this instance was constructed with before it was
normalized to the standard name returned by #getName.
|
|
Return an array of ISO script codes whose characters can be encoded with this
character set.
|
|
Return whether or not characters larger than 1 byte use the big endian order
or little endian.
|
|
Return true if this is a multibyte character set, or false for a fixed
width character set.
|
Class Detail
Charset(options)
- Parameters:
- {Object=} options
- options which govern the construction of this instance
- See:
- for information about registering a loader callback instance
Method Detail
{string}
getDescription()
Return a short description of the character set.
- Returns:
- {string} a description of the character set
{number}
getMaxCharWidth()
Return the largest number of bytes that a single character in this charset
could use.
- Returns:
- {number} the largest number of bytes that a single character in this charset uses
{number}
getMinCharWidth()
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.
- Returns:
- {number} the smallest number of bytes that a single character in this charset uses
{string}
getName()
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.
- Returns:
- {string} the name of the charset
{string}
getOriginalName()
Return the original name that this instance was constructed with before it was
normalized to the standard name returned by #getName.
- Returns:
- {string} the original name that this instance was constructed with
{Array.}
getScripts()
Return an array of ISO script codes whose characters can be encoded with this
character set.
- Returns:
- {Array.
} an array of ISO script codes supported by this charset
{boolean}
isBigEndian()
Return whether or not characters larger than 1 byte use the big endian order
or little endian.
- Returns:
- {boolean} true if this character set uses big endian order, or false otherwise
{boolean}
isMultibyte()
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.
- Returns:
- {boolean} true if this is a multibyte charset, or false otherwise