Skip to main content

string_escape

Function string_escape 

Source
pub fn string_escape(unescaped_str: &str, prefix: &str) -> RUMString
Expand description

Escape UTF-8 characters in UTF-8 string that are beyond ascii range

§Example

 use rumtk_core::strings::{string_escape, ASCII_ESCAPE_PREFIX_DEFAULT};
 let message = "I ❤ my wife!";
 let expected = "I \\x2764 my wife!";
 let escaped_message = string_escape(&message, ASCII_ESCAPE_PREFIX_DEFAULT);
 assert_eq!(expected, &escaped_message, "Did not get expected escaped string! Got {}!", &escaped_message);