"Unescapes" (JavaScript) strings with escape sequences written out as literal characters.
extern crate unescape;
use unescape::unescape;
fn main() {
println!("{}", unescape(r"\u0038\u0039").unwrap()); // prints out "89"
}
"Unescapes" strings with escape sequences written with literal characters and converts it into a properly escaped one.
License: MIT License
I am currently trying to use this crate to unescape some javascript strings, however the following examples are failing to unescape.
js literal | escaped | node's value |
---|---|---|
'\1\00\400\000' |
"'\\1\\00\\400\\000'" |
'\u0001\u0000 0\u0000' |
'\'\\"\\\b\f\n\r\t\v\0' |
"'\\'\\\"\\\\\\b\\f\\n\\r\\t\\v\\0'" |
'\\"\\\b\f\n\r\t\u000b\u0000 |
In the above table, the first cell represents a valid js string with escape sequences. The next column represents how that would be represented as a &str in Rust. The third column is the anticipated output, however the unescape
function this crate exports returns None
for both examples.
I found this package while looking for a package that takes a Rust string and spits out an escaped JS string. Being able to go back/forth (or in my case the opposite direction) would be very helpful
unescape(r#"\r\y\n"#) returns None but does not tell us where the problem is (either position or range).
This could be used in the solang compiler so that it can return the exact position for an error.
https://github.com/hyperledger-labs/solang/blob/master/src/cfg.rs#L771
First, thanks for writing this awesome crate.
But it looks like the author is busy. The last commit was about seven years ago. And some PRs hanging for years.
I made some improvements based on this project.
#![deny(missing_docs)]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.