Constructor
new unicodeJS.TextString(text)
#
This class provides a simple interface to fetching plain text from a data source. The base class reads data from a string, but an extended class could provide access to a more complex structure, e.g. an array or an HTML document tree.
Parameters:
Name | Type | Description |
---|---|---|
text |
string | Text |
- Source:
Methods
isMidSurrogate(position) → {boolean}
#
Check if the current offset is in the middle of a surrogate pair
Parameters:
Name | Type | Description |
---|---|---|
position |
number | Position |
- Source:
Returns:
- Type
- boolean
nextCodepoint(position) → {string|null
}
#
null
}
#
Read unicode codepoint after the specified offset
This is the same as the code unit (=Javascript character) at that offset, unless a valid surrogate pair ends at that code unit. (This is consistent with the behaviour of String.prototype.codePointAt)
Parameters:
Name | Type | Description |
---|---|---|
position |
number | Position |
- Source:
Returns:
Unicode codepoint, or null if out of bounds
- Type
-
string
|
null
prevCodepoint(position) → {string|null
}
#
null
}
#
Read unicode codepoint before the specified offset
This is the same as the code unit (=Javascript character) at the previous offset, unless a valid surrogate pair ends at that offset.
Parameters:
Name | Type | Description |
---|---|---|
position |
number | Position |
- Source:
Returns:
Unicode codepoint, or null if out of bounds
- Type
-
string
|
null
read(position) → {string|null
}
#
null
}
#
Read code unit at specified position
Parameters:
Name | Type | Description |
---|---|---|
position |
number | Position to read from |
- Source:
Returns:
Code unit, or null if out of bounds
- Type
-
string
|
null
toString() → {string}
#
Get as a plain string
- Source:
Returns:
Plain javascript string
- Type
- string