pub struct UChar { /* private fields */ }
Expand description

The implementation of the ICU UChar*.

While the original type is defined in umachine.h, most useful functions for manipulating UChar* are in fact here.

The first thing you probably want to do is to start from a UTF-8 rust string, produce a UChar. This is necessarily done with a conversion. See the TryFrom implementations in this crate for that.

Implements UChar* from ICU.

Implementations

Allocates a new UChar with given capacity.

Capacity and size must always be the same with UChar when used for interacting with low-level code.

Creates a new crate::UChar from its low-level representation, a buffer pointer and a buffer size.

Does not take ownership of the buffer that was passed in.

DO NOT USE UNLESS YOU HAVE NO OTHER CHOICE.

Safety

rep must point to an initialized sequence of at least len UChars.

Converts into a zeroed-out string.

This is a very weird ICU API thing, where there apparently exists a zero-terminated UChar*.

Returns the constant pointer to the underlying C representation. Intended for use in low-level code.

Returns the length of the string, in code points.

Returns whether the string is empty.

Returns the underlying representation as a mutable C representation. Caller MUST ensure that the representation won’t be reallocated as result of adding anything to it, and that it is correctly sized, or bad things will happen.

Resizes this string to match new_size.

If the string is made longer, the new space is filled with zeroes.

Returns the equivalent UTF-8 string, useful for debugging.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Adopts a vector of sys::UChar into a string.

Tries to produce a UTF-8 encoded rust string from a UChar.

This conversion ignores warnings and only reports actual ICU errors when they happen.

Implements u_strToUTF8.

The type returned in the event of a conversion error.

Tries to produce a string from the UTF-8 encoded thing.

This conversion ignores warnings (e.g. warnings about unterminated buffers), since for rust they are not relevant.

Implements u_strFromUTF8.

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.