mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-28 07:51:07 +00:00
commit
13269a9e2e
@ -111,6 +111,15 @@ extern "C" {
|
|||||||
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn escape(string: &str) -> JsString;
|
pub fn escape(string: &str) -> JsString;
|
||||||
|
|
||||||
|
/// The unescape() function computes a new string in which hexadecimal escape
|
||||||
|
/// sequences are replaced with the character that it represents. The escape sequences might
|
||||||
|
/// be introduced by a function like escape. Usually, decodeURI or decodeURIComponent
|
||||||
|
/// are preferred over unescape.
|
||||||
|
///
|
||||||
|
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub fn unescape(string: &str) -> JsString;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Array
|
// Array
|
||||||
|
@ -80,3 +80,11 @@ fn test_escape() {
|
|||||||
assert_eq!(String::from(escape("ć")), "%u0107");
|
assert_eq!(String::from(escape("ć")), "%u0107");
|
||||||
assert_eq!(String::from(escape("@*_+-./")), "@*_+-./");
|
assert_eq!(String::from(escape("@*_+-./")), "@*_+-./");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn test_unescape() {
|
||||||
|
assert_eq!(String::from(unescape("abc123")), "abc123");
|
||||||
|
assert_eq!(String::from(unescape("%E4%F6%FC")), "äöü");
|
||||||
|
assert_eq!(String::from(unescape("%u0107")), "ć");
|
||||||
|
assert_eq!(String::from(unescape("@*_+-./")), "@*_+-./");
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user