Feel free to fork if you see possible improvements!
npm install wtf-8
bower install wtf-8
component install mathiasbynens/wtf-8
In a browser:
var wtf8 = ;
Using an AMD loader like RequireJS:
string) as WTF-8, and returns the WTF-8-encoded version of the string.
// U+00A9 COPYRIGHT SIGN; seewtf8;// → '\xC2\xA9'// U+10001 LINEAR B SYLLABLE B038 E; seewtf8;// → '\xF0\x90\x80\x81'
Decodes any given WTF-8-encoded string (
byteString) as WTF-8, and returns the WTF-8-decoded version of the string. It throws an error when malformed WTF-8 is detected.
wtf8;// → '\xA9'wtf8;// → '\uD800\uDC01'// → U+10001 LINEAR B SYLLABLE B038 E
A string representing the semantic version number.
wtf-8 has been tested in (at least) the latest versions of Chrome, Opera, Firefox, Safari, IE, Node.js, Narwhal, RingoJS, PhantomJS, and Rhino.
wtf-8 is available under the MIT license.