All Projects → mathiasbynens → Utf8.js

mathiasbynens / Utf8.js

Licence: mit
A robust JavaScript implementation of a UTF-8 encoder/decoder, as defined by the Encoding Standard.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Utf8.js

He
A robust HTML entity encoder/decoder written in JavaScript.
Stars: ✭ 2,973 (+562.14%)
Mutual labels:  decoder, encoder
Tiny Utf8
Unicode (UTF-8) capable std::string
Stars: ✭ 322 (-28.29%)
Mutual labels:  decoder, encoder
aiff
Battle tested aiff decoder/encoder
Stars: ✭ 20 (-95.55%)
Mutual labels:  encoder, decoder
Keras Transformer
Transformer implemented in Keras
Stars: ✭ 273 (-39.2%)
Mutual labels:  decoder, encoder
Ultrajson
Ultra fast JSON decoder and encoder written in C with Python bindings
Stars: ✭ 3,504 (+680.4%)
Mutual labels:  decoder, encoder
fadec
A fast and lightweight decoder for x86 and x86-64 and encoder for x86-64.
Stars: ✭ 44 (-90.2%)
Mutual labels:  encoder, decoder
Flask Session Cookie Manager
🍪 Flask Session Cookie Decoder/Encoder
Stars: ✭ 257 (-42.76%)
Mutual labels:  decoder, encoder
otfed
An OpenType font format encoder & decoder written in OCaml
Stars: ✭ 15 (-96.66%)
Mutual labels:  encoder, decoder
Ffmpegcommand
FFmpegCommand适用于Android的FFmpeg命令库,实现了对音视频相关的处理,能够快速的处理音视频,大概功能包括:音视频剪切,音视频转码,音视频解码原始数据,音视频编码,视频转图片或gif,视频添加水印,多画面拼接,音频混音,视频亮度和对比度,音频淡入和淡出效果等
Stars: ✭ 394 (-12.25%)
Mutual labels:  decoder, encoder
schifra
C++ Reed Solomon Error Correcting Library https://www.schifra.com
Stars: ✭ 28 (-93.76%)
Mutual labels:  encoder, decoder
pytextcodifier
📦 Turn your text files into codified images or your codified images into text files.
Stars: ✭ 14 (-96.88%)
Mutual labels:  encoder, decoder
IkigaJSON
A high performance JSON library in Swift
Stars: ✭ 316 (-29.62%)
Mutual labels:  encoder, decoder
audio
Audio support for Go language.
Stars: ✭ 62 (-86.19%)
Mutual labels:  encoder, decoder
Flif
Free Lossless Image Format
Stars: ✭ 3,668 (+716.93%)
Mutual labels:  decoder, encoder
Image deionising auto encoder
Noise removal from images using Convolutional autoencoder
Stars: ✭ 34 (-92.43%)
Mutual labels:  encoder, decoder
android-opus-codec
Implementation of Opus encoder and decoder in C++ for android with JNI
Stars: ✭ 44 (-90.2%)
Mutual labels:  encoder, decoder
keystore-go
A Go (golang) implementation of Java KeyStore encoder/decoder
Stars: ✭ 119 (-73.5%)
Mutual labels:  encoder, decoder
online-ethereum-abi-encoder-decoder
A quick online tool to abi-encode and abi-decode constructor arguments used in ethereum's solidity. https://adibas03.github.io/online-ethereum-abi-encoder-decoder/
Stars: ✭ 37 (-91.76%)
Mutual labels:  encoder, decoder
morse-pro
Library for manipulating Morse code text and sound. Understands prosigns and Farnsworth speed. Can create WAV files and analyse input from the microphone or audio files.
Stars: ✭ 85 (-81.07%)
Mutual labels:  encoder, decoder
AnimatedGif
📼 A high performance .NET library for reading and creating animated GIFs
Stars: ✭ 106 (-76.39%)
Mutual labels:  encoder, decoder

utf8.js Build status Code coverage status Dependency status

utf8.js is a well-tested UTF-8 encoder/decoder written in JavaScript. Unlike many other JavaScript solutions, it is designed to be a proper UTF-8 encoder/decoder: it can encode/decode any scalar Unicode code point values, as per the Encoding Standard. Here’s an online demo.

Feel free to fork if you see possible improvements!

Installation

Via npm:

npm install utf8

In a browser:

<script src="utf8.js"></script>

In Node.js:

const utf8 = require('utf8');

API

utf8.encode(string)

Encodes any given JavaScript string (string) as UTF-8, and returns the UTF-8-encoded version of the string. It throws an error if the input string contains a non-scalar value, i.e. a lone surrogate. (If you need to be able to encode non-scalar values as well, use WTF-8 instead.)

// U+00A9 COPYRIGHT SIGN; see http://codepoints.net/U+00A9
utf8.encode('\xA9');
// → '\xC2\xA9'
// U+10001 LINEAR B SYLLABLE B038 E; see http://codepoints.net/U+10001
utf8.encode('\uD800\uDC01');
// → '\xF0\x90\x80\x81'

utf8.decode(byteString)

Decodes any given UTF-8-encoded string (byteString) as UTF-8, and returns the UTF-8-decoded version of the string. It throws an error when malformed UTF-8 is detected. (If you need to be able to decode encoded non-scalar values as well, use WTF-8 instead.)

utf8.decode('\xC2\xA9');
// → '\xA9'

utf8.decode('\xF0\x90\x80\x81');
// → '\uD800\uDC01'
// → U+10001 LINEAR B SYLLABLE B038 E

utf8.version

A string representing the semantic version number.

Support

utf8.js has been tested in at least Chrome 27-39, Firefox 3-34, Safari 4-8, Opera 10-28, IE 6-11, Node.js v0.10.0, Narwhal 0.3.2, RingoJS 0.8-0.11, PhantomJS 1.9.0, and Rhino 1.7RC4.

Unit tests & code coverage

After cloning this repository, run npm install to install the dependencies needed for development and testing. You may want to install Istanbul globally using npm install istanbul -g.

Once that’s done, you can run the unit tests in Node using npm test or node tests/tests.js. To run the tests in Rhino, Ringo, Narwhal, PhantomJS, and web browsers as well, use grunt test.

To generate the code coverage report, use grunt cover.

FAQ

Why is the first release named v2.0.0? Haven’t you heard of semantic versioning?

Long before utf8.js was created, the utf8 module on npm was registered and used by another (slightly buggy) library. @ryanmcgrath was kind enough to give me access to the utf8 package on npm when I told him about utf8.js. Since there has already been a v1.0.0 release of the old library, and to avoid breaking backwards compatibility with projects that rely on the utf8 npm package, I decided the tag the first release of utf8.js as v2.0.0 and take it from there.

Author

twitter/mathias
Mathias Bynens

License

utf8.js is available under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].