mutf8Length
The summed mutf8Length for the characters in a subsequence of this one.
If that sum exceeds 65535
, or UShort.MAX_VALUE, then it will still be returned, but note that the selected range is too long to encode as a single Modified UTF-8 sequence; it must be split up, compressed, or encoded differently.
Assuming the startIndex and endIndex form a valid range in a sequence, charSequence
, then this will yield the same sum as:
charSequence.subSequence(startIndex, endIndex).mutf8Length
This can be used from Java sources as follows:
import me.nullicorn.mewteaf8.Mutf8Length;
/* ... */
Mutf8Length.of(charSequence, startIndex, endIndex)
Receiver
The characters to determine the collective length of, in bytes.
Return
the number of bytes needed to represent the range of characters as a Modified UTF-8 sequence.
Parameters
The index in the sequence to stop counting at.
This cannot exceed the length of the sequence, and cannot be less than the startIndex.
Throws
if startIndex is greater than the endIndex.
The summed mutf8Length for the characters in a subsection of this array.
The contract of this method is identical to that of CharSequence.mutf8Length, except...
CharSequence is replaced with CharArray
CharSequence.length is replaced with CharArray.size
CharSequence.lastIndex is replaced with CharArray.lastIndex
No IllegalArgumentException will be thrown if the array's size is negative because that is not possible
All parameters, exceptions, constraints, and notes from CharSequence.mutf8Length apply to this function as well.
This can be used from Java sources as follows:
import me.nullicorn.mewteaf8.Mutf8Length;
/* ... */
Mutf8Length.of(charArray, startIndex, endIndex)
See also
The number of bytes used to encode the character in a Modified UTF-8 sequence.
For characters in the range
'\u0001' .. '\u007F'
, this is1
For characters in the range
'\u0080' .. '\u07FF'
, this is2
For characters in the range
'\u0800' .. '\uFFFF'
, this is3
For the character
'\u0000'
, this is2
That list covers the entire range of a Char, so there are no other values to note.
This can be used from Java sources as follows:
import me.nullicorn.mewteaf8.Mutf8Length;
/* ... */
Mutf8Length.of(char)
Receiver
The character to check the Modified UTF-8 length of.
The summed mutf8Length for all the characters in the sequence.
This is an alias for CharSequence.mutf8Length with startIndex = 0
and endIndex = length
. The selected indices are guaranteed to be valid, so all IllegalArgumentExceptions documented at CharSequence.mutf8Length are guaranteed not to occur unless also documented on this property. Other than that, the contract & documentation for CharSequence.mutf8Length applies here as well.
This can be used from Java sources as follows:
import me.nullicorn.mewteaf8.Mutf8Length;
/* ... */
Mutf8Length.of(charSequence)
See also
Throws
if the length of the CharSequence is a negative number.
The summed mutf8Length for all the characters in the array.
This is an alias for CharArray.mutf8Length with startIndex = 0
and endIndex = size
. The selected indices are guaranteed to be valid, so all IllegalArgumentExceptions documented at CharArray.mutf8Length are guaranteed not to occur. Other than that, the contract & documentation for CharArray.mutf8Length applies here as well.
This can be used from Java sources as follows:
import me.nullicorn.mewteaf8.Mutf8Length;
/* ... */
Mutf8Length.of(charArray)