docs

bare::ffi::wide

本页内容

API 参考只有英文版,由标准库源代码中的英文文档注释生成。

NUL-terminated wchar_t strings: UTF-16 on Windows (the W APIs), one unit per char (UTF-32) elsewhere.

WideCStr and WideCString keep their units, NUL included, in one GC buffer the value holds, so as_ptr holds as CStr::as_ptr does. WideCStr::from_ptr copies.

Structs

WideCStrSource

pub struct WideCStr

A NUL-terminated wchar_t string.

  • pub unsafe fn from_ptr(p: ConstPtr<c_wchar>) -> WideCStr | none§

    Source

    The wide C string at p, copied up to its NUL; none for a null pointer.

    Safety: p must be null or point at a live NUL-terminated wchar_t string.

  • pub fn as_ptr(self) -> ConstPtr<c_wchar>§

    Source

    A pointer to the first unit, for C; valid while self is alive.

  • pub fn as_units(self) -> Slice<c_wchar>§

    Source

    The units without the NUL.

  • pub fn as_units_with_nul(self) -> Slice<c_wchar>§

    Source

    The units with the trailing NUL.

  • pub fn to_str(self) throws (Utf16Error) -> str§

    Source

    The units before the NUL as a str; throws at an unpaired surrogate (elsewhere than Windows: a unit that is no char).

  • pub fn to_str_lossy(self) -> str§

    Source

    to_str with each bad unit replaced by U+FFFD.

  • pub const fn len(self) -> usize§

    Source

    Units before the NUL.

Trait implementations 5

WideCStringSource

pub struct WideCString

An owned NUL-terminated wchar_t string.

  • pub fn new(s: str) throws (NulError) -> WideCString§

    Source

    s as wchar_t units and a NUL; throws if s has a NUL of its own (position is its unit index).

  • pub const fn as_wide_cstr(self) -> WideCStr§

    Source

    The borrowed wide C string (with its NUL), valid while self is alive.

  • pub fn as_ptr(self) -> ConstPtr<c_wchar>§

    Source

    A pointer to the first unit, for C; valid while self is alive.

  • pub fn as_units(self) -> Slice<c_wchar>§

    Source

    The units without the NUL.

  • pub fn to_str(self) -> str§

    Source

    The string back; new took a str, so this never fails.

  • pub const fn len(self) -> usize§

    Source

    Units before the NUL.

Trait implementations 5
  • impl Clone for WideCString
  • impl PartialEq for WideCString
  • impl Eq for WideCString
  • impl Hash for WideCString
  • impl Debug for WideCString