core :: U16String :: defaultinit
U16String
of capacity cap
or a NULL U16String
if no cap
parameter is provided.The cap
argument is the number of code units (aka UTF-16 encoded characters or UChar
) allocated to uchar_string
.
If the number of code units is known in advance, it can be provided with the units
parameter.
# Returns an empty `U16String` of capacity `cap` or a NULL `U16String` if no `cap` parameter is provided.
# The `cap` argument is the number of code units (aka UTF-16 encoded characters or `UChar`) allocated to `uchar_string`.
# If the number of code units is known in advance, it can be provided with the `units` parameter.
init (cap: nullable Int, units: nullable Int) do
if cap == null then
uchar_string = new UCharString.nul
else
assert cap >= 0
if not units == null then
assert units <= cap
code_units = units
end
uchar_string = new UCharString.empty(cap)
capacity = cap
end
end
lib/core/text/u16_string.nit:47,2--64,4