encode symbol as alphanumeric by hex-encoding special characters
(input: &str)
| 10 | |
| 11 | /// encode symbol as alphanumeric by hex-encoding special characters |
| 12 | pub fn make_external_component(input: &str) -> String { |
| 13 | input |
| 14 | .chars() |
| 15 | .map(|c| match c { |
| 16 | 'A'..='Z' | 'a'..='z' | '0'..='9' | '_' => { |
| 17 | let mut s = String::new(); |
| 18 | s.push(c); |
| 19 | s |
| 20 | } |
| 21 | '-' => { |
| 22 | let mut s = String::new(); |
| 23 | s.push('_'); |
| 24 | s |
| 25 | } |
| 26 | _ => { |
| 27 | let mut s = String::from("X"); |
| 28 | s.push(hexdigit((c as u32 & 0xf0) >> 4)); |
| 29 | s.push(hexdigit(c as u32 & 0xf)); |
| 30 | s |
| 31 | } |
| 32 | }) |
| 33 | .collect() |
| 34 | } |
| 35 | |
| 36 | /// encode symbol as alphanumeric by hex-encoding special characters |
| 37 | pub fn make_external_symbol(module_name: &str, name: &str, variant: abi::AbiVariant) -> String { |
no test coverage detected