core :: UCharString
UChar *
which are UTF-16 stringscore :: UCharString :: char_at_offset
Get code point at code unitoffset
core :: UCharString :: code_points
Returns the number of code points up tocode_units
characters
core :: UCharString :: defaultinit
core :: UCharString :: empty
Returns an emptyUCharString
of length length
core :: UCharString :: from_cstring
Converts aCString
to a UCharString
and returns the required length of said UCharString
core :: UCharString :: to_cstring
Convertsself
to a CString
and returns the required length (without the termination character) of said CString
core $ UCharString :: SELF
Type of this instance, automatically specialized in every classcore :: Pointer :: address_is_null
Is the address behind this Object at NULL?core :: UCharString :: char_at_offset
Get code point at code unitoffset
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: UCharString :: code_points
Returns the number of code points up tocode_units
characters
core :: Object :: defaultinit
core :: UCharString :: defaultinit
core :: Pointer :: defaultinit
core :: UCharString :: empty
Returns an emptyUCharString
of length length
core :: UCharString :: from_cstring
Converts aCString
to a UCharString
and returns the required length of said UCharString
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).core :: UCharString :: to_cstring
Convertsself
to a CString
and returns the required length (without the termination character) of said CString
# ICU string `UChar *` which are UTF-16 strings
extern class UCharString `{ UChar *`}
# Returns an empty `UCharString` of length `length`
new empty (length: Int) `{
UChar * str = (UChar *)malloc(sizeof(UChar) * length);
u_memset(str, 0, length);
return str;
`}
# Returns a `NULL` `UCharString`
new nul `{ return NULL; `}
# Returns the number of code points up to `code_units` characters
fun code_points(code_units: Int): Int `{
if (self == NULL) {
return -1;
}
return u_countChar32(self, code_units);
`}
# Converts a `CString` to a `UCharString` and returns the required length of said `UCharString`
fun from_cstring(dest_length: Int, source: CString, source_length: Int): Int `{
UErrorCode error = U_ZERO_ERROR;
int32_t res;
u_strFromUTF8(self, dest_length, &res, source, source_length, &error);
return res;
`}
# Converts `self` to a `CString` and returns the required length (without the termination character) of said `CString`
fun to_cstring(dest: CString, dest_length: Int, source_length: Int): Int `{
UErrorCode error = U_ZERO_ERROR;
int32_t res;
u_strToUTF8(dest, dest_length, &res, self, source_length, &error);
return res;
`}
# Get code point at code unit `offset`
fun char_at_offset(offset: Int, code_units: Int): Char `{
UChar32 c = 0;
U16_NEXT(self, offset, code_units, c);
return c;
`}
end
lib/core/text/u16_string.nit:144,1--187,3