pub struct Translit;Expand description
๐ ๐ ๏ธ Lossy text transliteration utilities.
Provides small, mostly const mappings
from Unicode scalars to simpler textual approximations.
๐ text
Implementationsยง
Sourceยงimpl Translit
impl Translit
Sourcepub const fn ascii(char: char) -> &'static str โ
Available on crate feature translit only.
pub const fn ascii(char: char) -> &'static str โ
translit only.Returns the ASCII transliteration of a Unicode scalar value.
This is a lossy transliteration, not an encoding. The result may contain zero, one, or more ASCII bytes.
Returns an empty string if the scalar is not mapped.
Converts Unicode to readable ASCII approximations:
'ยฐ'โ"deg"'ฮฑ'โ"a"'ยฉ'โ"(c)"'ไธญ'โ"Zhong "'๐'โ""- โฆ
Sourcepub const fn ascii_scalar(scalar: u32) -> &'static str โ
Available on crate feature translit only.
pub const fn ascii_scalar(scalar: u32) -> &'static str โ
translit only.Returns the ASCII transliteration of a Unicode scalar code point.
This accepts a raw u32 for table-oriented use.
Invalid or unmapped scalar values simply return an empty string.
ยงVendored
This is adapted work from transliteration.
Sourcepub fn ascii_of<S: UnicodeScalar>(scalar: S) -> &'static str โ
Available on crate feature translit only.
pub fn ascii_of<S: UnicodeScalar>(scalar: S) -> &'static str โ
translit only.Returns an ASCII approximation of any Unicode scalar type.
Sourcepub const fn has_ascii(c: char) -> bool
Available on crate feature translit only.
pub const fn has_ascii(c: char) -> bool
translit only.Returns whether the scalar has a non-empty ASCII approximation.
Sourcepub const fn has_ascii_scalar(scalar: u32) -> bool
Available on crate feature translit only.
pub const fn has_ascii_scalar(scalar: u32) -> bool
translit only.Returns whether the scalar code point has a non-empty ASCII approximation.
Sourcepub const fn ascii_or(c: char, fallback: &'static str) -> &'static str โ
Available on crate feature translit only.
pub const fn ascii_or(c: char, fallback: &'static str) -> &'static str โ
translit only.Returns an ASCII approximation, or fallback if the scalar is unmapped.
Sourcepub const fn ascii_scalar_or(
scalar: u32,
fallback: &'static str,
) -> &'static str โ
Available on crate feature translit only.
pub const fn ascii_scalar_or( scalar: u32, fallback: &'static str, ) -> &'static str โ
translit only.Returns an ASCII approximation, or fallback if the scalar is unmapped.
Sourcepub const fn ascii_byte(c: char) -> Option<u8> โ
Available on crate feature translit only.
pub const fn ascii_byte(c: char) -> Option<u8> โ
translit only.Returns the single ASCII byte approximation, if it is exactly one byte.
Sourcepub const fn ascii_scalar_byte(scalar: u32) -> Option<u8> โ
Available on crate feature translit only.
pub const fn ascii_scalar_byte(scalar: u32) -> Option<u8> โ
translit only.Returns the single ASCII byte approximation, if it is exactly one byte.
Sourcepub const fn ascii_len(c: char) -> usize
Available on crate feature translit only.
pub const fn ascii_len(c: char) -> usize
translit only.Returns the length of the ASCII approximation.
Sourcepub const fn ascii_scalar_len(scalar: u32) -> usize
Available on crate feature translit only.
pub const fn ascii_scalar_len(scalar: u32) -> usize
translit only.Returns the length of the ASCII approximation.
Trait Implementationsยง
Auto Trait Implementationsยง
impl Freeze for Translit
impl RefUnwindSafe for Translit
impl Send for Translit
impl Sync for Translit
impl Unpin for Translit
impl UnsafeUnpin for Translit
impl UnwindSafe for Translit
Blanket Implementationsยง
Sourceยงimpl<T> AnyExt for T
impl<T> AnyExt for T
Sourceยงfn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId of Self using a custom hasher.Sourceยงfn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Sourceยงfn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
alloc only.Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<T> ByteSized for T
impl<T> ByteSized for T
Sourceยงconst BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Sourceยงfn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Sourceยงfn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Sourceยงimpl<T> MemExt for Twhere
T: ?Sized,
impl<T> MemExt for Twhere
T: ?Sized,
Sourceยงconst NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Sourceยงfn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Sourceยงfn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Sourceยงfn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Sourceยงfn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Sourceยงfn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true if dropping values of this type matters. Read moreSourceยงfn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self without running its destructor. Read moreSourceยงfn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Sourceยงunsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSourceยงunsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSourceยงfn mem_as_bytes(&self) -> &[u8] โ
fn mem_as_bytes(&self) -> &[u8] โ
unsafe_slice only.