widestring
A wide string Rust library for converting to and from wide strings, such as those often used in Windows API or other FFI libaries. Both `u16` and `u32` string types are provided, including support for UTF-16 and UTF-32, malformed encoding, C-style strings, etc.
1.2.1
101M downloads/mo
#804 most downloaded on crates.io
VoidStarKat/widestring-rs
What this package is like to depend on
Last release 10 months ago
09 Oct 2025
Release timing varies
gaps range from 1 weeks to 1.8 years
Some releases are documented
notes for 9 of 16 stable releases
1 version withdrawn
withdrawn after publishing
11 years old
18 releases · first in 2016
1 release in the last 12 months
see the full history below
Release timeline
18 releases · Jan 2016 to Oct 2025Releases
latest 18-
1.2.109 Oct 2025Release notes
Open source →Changed
- Git repository URL has changed due to GitHub user name change. Old URL is redirected.
Fixed
trim_endcharacter boundary panic when processing 4-byte characters. By @syrflover.- Fixed completely broken
U16String::insert_charwhich always panicked. Fixes #46. - Documentation typos on
WideCStringtype alias. - Fixed
unused_importlint onwide*macros.
Added
- Added GDB pretty printers for
Utf32StringandUtf32Str. You can load them fromgdb/widestring.py.
-
1.2.015 Mar 2025Release notes
Open source →Changed
- Minor restructing of included license file locations to be more consistent with crates ecosystem.
- Moved to
windows-sysfor documentation tests instead of legacywinapicrate. Fixes #40.
Added
Fixed
- Removed panic in
Utf16String::truncatewhennew_lengreater than string length. Fixes #39. - Fixed various clippy warnings.
- Fixed debugger visualizer for Rust 1.82+ due to changes in
corelibrary structures.
-
1.1.006 Apr 2024Release notes
Open source →Added
Utf32String::into_char_vecand missing conversion toVec<char>forUtf32String. Fixes #37.include_utf16str!macro to include UTF-16 file at compile-time asUtf16Str. By @daxpedda.
Fixed
U16String::pop_charpanics with surrogate string. Fixes #38.- Various import warnings and new clippy warnings, plus stabilized debugger visualizer warnings.
-
1.0.215 Jul 2022Release notes
Open source →Fixed
- Correctly check for and error on nul values in C-string macros
u16cstr!,u32cstr!, andwidecstr!. Fixes #28.
- Correctly check for and error on nul values in C-string macros
-
1.0.124 Jun 2022 -
1.0.021 Jun 2022Release notes
Open source →Changed
- Breaking Change Minimum supported Rust version is now 1.58.
- Added
#[must_use]attributes to many crate functions, as appropriate. - Remove
unsafequalifiers fromas_mut_ptrandas_mut_ptr_rangeto match standard library. By @yescallop.
Added
- Added
newfunction that creates and empty string toU16CStringandU32CStringto match other string types. - Additional
Fromimplementations for conversion toOsString.
Also see the changes in 1.0.0-beta.1 if upgrading from 0.5.1 or earlier.
-
1.0.0-beta.108 Nov 2021 pre-releaseRelease notes
Open source →Changed
- Breaking Change Minimum supported Rust version is now 1.56.
- Breaking Change The following methods on
U16StringandU32Stringhave been renamed and replaced by functions with different semantics:popis nowpop_charremoveis nowremove_charinsertis nowinsert_char
- Breaking Change Moved and renamed the following iterator types:
iter::Utf16Charsrenamed toCharsUtf16and moved toustranducstriter::Utf32Charsrenamed toCharsUtf32and moved toustranducstriter::CharsLossysplit and renamed toCharsLossyUtf16andCharsLossyUtf32and moved toustranducstriter::Utf16CharIndicesrenamed toCharIndicesUtf16and moved toustranducstriter::Utf16CharIndicesLossyrenamed toCharIndicesLossyUtf16and moved toustranducstr
- Breaking Change
error::FromUtf16Erroranderror::FromUtf32Errorhas been renamed toUtf16ErrorandUtf32Errorrespectively and expanded with more details about the error. - Migrated crate to Rust 2021 edition.
- The following methods on
U16StrandU32Strare nowconst:from_sliceas_sliceas_ptrlenis_empty
- The following methods on
U16CStrandU32CStrare nowconst:from_slice_uncheckedas_slice_with_nulas_ptrlenis_empty
- The following methods on
U16StringandU32Stringare nowconst:new
Added
- Added new UTF-encoded string types and associated types:
Utf16StrUtf32StrUtf16StringUtf32String
- Added macros to convert string literals into
constwide string slices:u16str!u16cstr!u32str!u32cstr!widestr!widecstr!utf16str!utf32str!
- Added
NUL_TERMINATORassociated constant toU16CStr,U32CStr,U16CString, andU32CString. - Added
DoubleEndedIteratorandExactSizeIteratorimplementations to a number of iterator types. - Added new UTF encoding functions alongside existing decode functions:
encode_utf8encode_utf16encode_utf32
- Added various methods:
repeatonU16Str,U32Str,U16CStr, andU32CStrshrink_toonU16StringandU32StringretainonU16StringandU32StringdrainonU16StringandU32Stringreplace_rangeonU16StringandU32Stringget,get_mut,get_unchecked, andget_unchecked_mutonU16CStrandU32CStrsplit_atandsplit_at_mutonU16CStrandU32CStr
- Added more trait implementations.
Removed
- Breaking Change Functions and types deprecated in 0.5 have been removed.
- Breaking Change The following types and traits, which were implementation details, have been removed. Use the existing non-generic types instead (e.g. use
U16Strinstead ofUStr<u16>).UCharUStrUCStrUStringUCString
- Breaking Change Removed
IndexMut<RangeFull>trait implementation ofU16CStringandU32CString. Use the unsafeget_mutmethod instead, which also supports more ranges.
Fixed
- Breaking Change The iterator returned by
U16Str::char_indicesandU16CStr::char_indicesis now over(usize, Result<char, DecodeUtf16Error>)tuples instead of the reverse order, to better match standard library string iterators. The same is true ofU16Str::char_indices_lossyandU16CStr::char_indices_lossy. This matches what was stated in original documentation. U32Str::to_stringandU32CStr::to_stringnow only allocate once instead of twice.
-
0.5.123 Oct 2021Release notes
Open source →Fixed
- Fixed a regression in 0.5.0 where zero-length vectors and strings were incorrectly causing panics in
UCString::from_vecandUCString::from_str. Fixes #22. - Modified an implentation detail in
ustr::to_string&ustr::to_string_lossyto remove possibly unsafe behaviour.
- Fixed a regression in 0.5.0 where zero-length vectors and strings were incorrectly causing panics in
-
0.5.012 Oct 2021Release notes
Open source →Changed
- Breaking Change Renamed a number of types and functions to increase consistency and clarity. This also meant renaming errors to more clearly convey error and trying to be more consistent with name conventions and functionality across types. Check renamed function docs for any changes in functionality, as there have been some minor tweaks (mostly relaxing/removing error conditions and reducing panics). Old names have been deprecated to ease transition and will be removed in a future release. Fixes #18.
MissingNulError=>error::MissingNulTerminatorFromUtf32Error=>error::FromUtf32ErrorNulError=>error::ContainsNulUCStr::from_ptr_with_nul=>from_ptr_uncheckedUCStr::from_slice_with_nul=>from_slice_truncateUCStr::from_slice_with_nul_unchecked=>from_slice_uncheckedU32CStr::from_char_ptr_with_nul=>from_char_ptr_uncheckedU32CStr::from_char_slice_with_nul=>from_char_slice_truncateU32CStr::from_char_slice_with_nul_unchecked=>from_char_slice_uncheckedUCString::new=>from_vecUCString::from_vec_with_nul=>from_vec_truncateUCString::from_ustr_with_nul=>from_ustr_truncateUCString::from_ptr_with_nul=>from_ptr_truncateUCString::from_str_with_nul=>from_str_truncateUCString::from_os_str_with_nul=>from_os_str_truncateU32CString::from_chars_with_nul=>from_chars_truncateU32CString::from_char_ptr_with_nul=>from_char_ptr_truncate
- Deprecated error types in the crate root. Use the errors directly from
errormodule instead. - Improved implementations in some areas to reduce unncessary double allocations.
- Improved
Debugimplementations. No more debugging lists of raw integer values. - Migrated crate to Rust 2018 edition.
- Minimum supported Rust version is now 1.48.
- Made crate package REUSE compliant.
- Improved documentation and used intra-doc links.
Added
- Added crate-level functions
decode_utf16,decode_utf16_lossy,decode_utf32, anddecode_utf32_lossyand associated iterators. Note thatdecode_utf16is an alias ofcore::char::decode_utf16, but provided for consistency. - Added
displaymethod to to bothUStrandUCStrto display strings in formatting without heap allocations, similar toPath::display. Fixes #20. - Added more trait implementations, including more index operations and string formatting via
Writetrait. Fixes #19. - Added new functions:
UStr::from_ptr_mutUStr::from_slice_mutUStr::as_mut_sliceUStr::as_mut_ptrUStr::as_ptr_rangeUStr::as_mut_ptr_rangeUStr::getUStr::get_mutUStr::get_uncheckedUStr::get_unchecked_mutUStr::split_atUStr::split_at_mutUStr::charsUStr::chars_lossyU16Str::char_indicesU16Str::char_indices_lossyU32Str::from_char_ptr_mutU32Str::from_char_slice_mutUCStr::from_ptrUCStr::from_ptr_truncateUCStr::from_sliceUCStr::as_ustrUCStr::from_ptr_str_mutUCStr::from_ptr_mutUCStr::from_ptr_truncate_mutUCStr::from_ptr_unchecked_mutUCStr::from_slice_mutUCStr::from_slice_truncate_mutUCStr::from_slice_unchecked_mutUCStr::as_mut_sliceUCStr::as_mut_ptrUCStr::as_ustr_with_nulUCStr::as_mut_ustrUCStr::as_ptr_rangeUCStr::as_mut_ptr_rangeUCStr::charsUCStr::chars_lossyU16CStr::char_indicesU16CStr::char_indices_lossyU32CStr::from_char_ptr_str_mutU32CStr::from_char_ptr_mutU32CStr::from_char_ptr_truncate_mutU32CStr::from_char_ptr_unchecked_mutU32CStr::from_char_slice_mutU32CStr::from_char_slice_truncate_mutU32CStr::from_char_slice_unchecked_mutU32CStr::from_char_ptrU32CStr::from_char_ptr_truncateU32CStr::from_char_sliceUString::as_vecUString::as_mut_vecUString::push_charUString::truncateUString::popUString::removeUString::insertUString::insert_ustrUString::split_offUCString::as_mut_ucstrUCString::into_ustringUCString::into_ustring_with_nulU32CString::from_char_ptr_str
Deprecated
- Deprecated functions as part of simplifying to increase clarity. These will be removed entirely in a future release.
UCString::from_vec_with_nul_unchecked. Usefrom_vec_uncheckedinstead.UCString::from_ustr_with_nul_unchecked. Usefrom_ustr_uncheckedinstead.UCString::from_ptr_with_nul_unchecked. Usefrom_ptr_uncheckedinstead.UCString::from_str_with_nul_unchecked. Usefrom_str_uncheckedinstead.UCString::from_os_str_with_nul_unchecked. Usefrom_os_str_uncheckedinstead.U32CString::from_chars_with_nul_unchecked. Usefrom_chars_uncheckedinstead.U32CString::from_char_ptr_with_nul_unchecked. Usefrom_char_ptr_uncheckedinstead.
- Breaking Change Renamed a number of types and functions to increase consistency and clarity. This also meant renaming errors to more clearly convey error and trying to be more consistent with name conventions and functionality across types. Check renamed function docs for any changes in functionality, as there have been some minor tweaks (mostly relaxing/removing error conditions and reducing panics). Old names have been deprecated to ease transition and will be removed in a future release. Fixes #18.
-
0.4.305 Oct 2020Nothing published for this version
-
0.4.209 Jun 2020Release notes
Open source →Fixed
- Fixed compile errors on pre-1.36.0 Rust due to unstable
alloccrate. Minimum supported version is Rust 1.34.2, the rust version for Debian stable. Fixes #14
- Fixed compile errors on pre-1.36.0 Rust due to unstable
-
0.4.108 Jun 2020 withdrawnNothing published for this version
-
0.4.018 Aug 2018Nothing published for this version
-
0.3.017 Mar 2018Nothing published for this version
-
0.2.209 Sep 2016Nothing published for this version
-
0.2.112 Aug 2016Nothing published for this version
-
0.2.031 May 2016Nothing published for this version
-
0.1.025 Jan 2016Nothing published for this version