char
fn char(byte b) -> Result<string, string>
Source: compiler/src/builtin_docs/prelude.hy Returns the one-character string whose code point is b.
Values 0..=127 give an ASCII character; 128..=255 give the Latin-1
character with that code point (two bytes of UTF-8, so char(233) is
"é"). The result is Err("byte out of range") only if the value is
outside 0..=255, which a well-typed byte never is. The inverse is ord.
Parameters#
| Name | Type |
|---|---|
b | byte |
Returns#
Result<string, string>
Examples#
use tests::assert;
let s = match char(66 as byte) {
Result::Ok(c) => c,
Result::Err(_) => "",
};
assert!(s == "B");