use super::funejson::Value; /// Text as UTF-8 bytes. A Rust string is already UTF-8, so this is its bytes /// as integers; a lone surrogate, which TypeScript and Python turn into /// U+FFFD, cannot occur in a `&str`. pub fn utf8_encode(text: &str) -> Vec { text.as_bytes().iter().map(|&b| b as i64).collect() } pub fn fune_vector(args: &[Value]) -> Value { let text = match &args[0] { Value::Str(s) => s.as_str(), _ => panic!("text must be a string"), }; Value::Arr(utf8_encode(text).into_iter().map(Value::Int).collect()) }