A wide string Rust library for converting to and from wide-character strings, including UTF-16 and UTF-32 encoding.
Utf32String::into_char_vec
and missing conversion to Vec<char>
for Utf32String
. Fixes #37.include_utf16str!
macro to include UTF-16 file at compile-time as Utf16Str
. By @daxpedda.U16String::pop_char
panics with surrogate string. Fixes #38.#[must_use]
attributes to many crate functions, as appropriate.unsafe
qualifiers from as_mut_ptr
and as_mut_ptr_range
to match standard library. By @yescallop.new
function that creates and empty string to U16CString
and U32CString
to match other string types.From
implementations for conversion to OsString
.Also see the changes in 1.0.0-beta.1 if upgrading from 0.5.1 or earlier.
U16String
and U32String
have been renamed and replaced by functions with different semantics:
pop
is now pop_char
remove
is now remove_char
insert
is now insert_char
iter::Utf16Chars
renamed to CharsUtf16
and moved to ustr
and ucstr
iter::Utf32Chars
renamed to CharsUtf32
and moved to ustr
and ucstr
iter::CharsLossy
split and renamed to CharsLossyUtf16
and CharsLossyUtf32
and moved to ustr
and ucstr
iter::Utf16CharIndices
renamed to CharIndicesUtf16
and moved to ustr
and ucstr
iter::Utf16CharIndicesLossy
renamed to CharIndicesLossyUtf16
and moved to ustr
and ucstr
error::FromUtf16Error
and error::FromUtf32Error
has been renamed to Utf16Error
and Utf32Error
respectively and expanded with more details about the error.U16Str
and U32Str
are now const
:
from_slice
as_slice
as_ptr
len
is_empty
U16CStr
and U32CStr
are now const
:
from_slice_unchecked
as_slice_with_nul
as_ptr
len
is_empty
U16String
and U32String
are now const
:
new
Utf16Str
Utf32Str
Utf16String
Utf32String
const
wide string slices:
u16str!
u16cstr!
u32str!
u32cstr!
widestr!
widecstr!
utf16str!
utf32str!
NUL_TERMINATOR
associated constant to U16CStr
, U32CStr
, U16CString
, and U32CString
.DoubleEndedIterator
and ExactSizeIterator
implementations to a number of iterator types.encode_utf8
encode_utf16
encode_utf32
repeat
on U16Str
, U32Str
, U16CStr
, and U32CStr
shrink_to
on U16String
and U32String
retain
on U16String
and U32String
drain
on U16String
and U32String
replace_range
on U16String
and U32String
get
, get_mut
, get_unchecked
, and get_unchecked_mut
on U16CStr
and U32CStr
split_at
and split_at_mut
on U16CStr
and U32CStr
U16Str
instead of UStr<u16>
).
UChar
UStr
UCStr
UString
UCString
IndexMut<RangeFull>
trait implementation of U16CString
and U32CString
. Use the unsafe get_mut
method instead, which also supports more ranges.U16Str::char_indices
and U16CStr::char_indices
is now over (usize, Result<char, DecodeUtf16Error>)
tuples instead of the reverse order, to better match standard library string iterators. The same is true of U16Str::char_indices_lossy
and U16CStr::char_indices_lossy
. This matches what was stated in original documentation.U32Str::to_string
and U32CStr::to_string
now only allocate once instead of twice.MissingNulError
=> error::MissingNulTerminator
FromUtf32Error
=> error::FromUtf32Error
NulError
=> error::ContainsNul
UCStr::from_ptr_with_nul
=> from_ptr_unchecked
UCStr::from_slice_with_nul
=> from_slice_truncate
UCStr::from_slice_with_nul_unchecked
=> from_slice_unchecked
U32CStr::from_char_ptr_with_nul
=> from_char_ptr_unchecked
U32CStr::from_char_slice_with_nul
=> from_char_slice_truncate
U32CStr::from_char_slice_with_nul_unchecked
=> from_char_slice_unchecked
UCString::new
=> from_vec
UCString::from_vec_with_nul
=> from_vec_truncate
UCString::from_ustr_with_nul
=> from_ustr_truncate
UCString::from_ptr_with_nul
=> from_ptr_truncate
UCString::from_str_with_nul
=> from_str_truncate
UCString::from_os_str_with_nul
=> from_os_str_truncate
U32CString::from_chars_with_nul
=> from_chars_truncate
U32CString::from_char_ptr_with_nul
=> from_char_ptr_truncate
error
module instead.Debug
implementations. No more debugging lists of raw integer values.decode_utf16
, decode_utf16_lossy
, decode_utf32
, and decode_utf32_lossy
and associated iterators. Note that decode_utf16
is an alias of core::char::decode_utf16
, but provided for consistency.display
method to to both UStr
and UCStr
to display strings in formatting without heap allocations, similar to Path::display
. Fixes #20.Write
trait. Fixes #19.UStr::from_ptr_mut
UStr::from_slice_mut
UStr::as_mut_slice
UStr::as_mut_ptr
UStr::as_ptr_range
UStr::as_mut_ptr_range
UStr::get
UStr::get_mut
UStr::get_unchecked
UStr::get_unchecked_mut
UStr::split_at
UStr::split_at_mut
UStr::chars
UStr::chars_lossy
U16Str::char_indices
U16Str::char_indices_lossy
U32Str::from_char_ptr_mut
U32Str::from_char_slice_mut
UCStr::from_ptr
UCStr::from_ptr_truncate
UCStr::from_slice
UCStr::as_ustr
UCStr::from_ptr_str_mut
UCStr::from_ptr_mut
UCStr::from_ptr_truncate_mut
UCStr::from_ptr_unchecked_mut
UCStr::from_slice_mut
UCStr::from_slice_truncate_mut
UCStr::from_slice_unchecked_mut
UCStr::as_mut_slice
UCStr::as_mut_ptr
UCStr::as_ustr_with_nul
UCStr::as_mut_ustr
UCStr::as_ptr_range
UCStr::as_mut_ptr_range
UCStr::chars
UCStr::chars_lossy
U16CStr::char_indices
U16CStr::char_indices_lossy
U32CStr::from_char_ptr_str_mut
U32CStr::from_char_ptr_mut
U32CStr::from_char_ptr_truncate_mut
U32CStr::from_char_ptr_unchecked_mut
U32CStr::from_char_slice_mut
U32CStr::from_char_slice_truncate_mut
U32CStr::from_char_slice_unchecked_mut
U32CStr::from_char_ptr
U32CStr::from_char_ptr_truncate
U32CStr::from_char_slice
UString::as_vec
UString::as_mut_vec
UString::push_char
UString::truncate
UString::pop
UString::remove
UString::insert
UString::insert_ustr
UString::split_off
UCString::as_mut_ucstr
UCString::into_ustring
UCString::into_ustring_with_nul
U32CString::from_char_ptr_str
UCString::from_vec_with_nul_unchecked
. Use from_vec_unchecked
instead.UCString::from_ustr_with_nul_unchecked
. Use from_ustr_unchecked
instead.UCString::from_ptr_with_nul_unchecked
. Use from_ptr_unchecked
instead.UCString::from_str_with_nul_unchecked
. Use from_str_unchecked
instead.UCString::from_os_str_with_nul_unchecked
. Use from_os_str_unchecked
instead.U32CString::from_chars_with_nul_unchecked
. Use from_chars_unchecked
instead.U32CString::from_char_ptr_with_nul_unchecked
. Use from_char_ptr_unchecked
instead.U32String
, U32Str
, U32CString
, and U32CStr
types for dealing with UTF-32 FFI. These
new types are roughly equivalent to the existing UTF-16 types.WideChar
is a type alias to u16
on Windows but u32
on non-Windows platforms.UString
, UStr
, UCString
and UCStr
are used to implement the string
types.U16String
, U16Str
,
U16CString
, and U16CStr
(previously WideString
, WideStr
, etc.). Some function have
also been renamed to reflect this change (wide_str
to u16_str
, etc.).WideString
, WideStr
, WideCString
, and WideCStr
are now type aliases
that vary between platforms. On Windows, these are aliases to the U16
types and are equivalent
to the previous version, but on non-Windows platforms these alias the new U32
types instead.
See crate documentation for more details.