std-method
char::len_utf16
Determine whether a scalar needs one or two UTF-16 code units. Expected stdout (not executed): 1 2 Common mistake: Assuming all characters occupy exactly one u16.
Formal Syntax & Structure
rust syntaxrust
fn len_utf16(self) -> usizeWorking Example
Example Snippetrust
fn main() { println!("{} {}", 'ش'.len_utf16(), '😀'.len_utf16());}