Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
utf8-buffer
Advanced tools
ES6 module to encode and decode UTF-8 strings.
Copyright (c) 2018 Rafael da Silva Rocha.
https://github.com/rochars/utf8-buffer
utf8-buffer is a ES6 module to encode and decode UTF-8 strings.
npm install utf8-buffer
You can also download one of the files in the ./dist folder:
https://github.com/rochars/utf8-buffer/tree/master/dist
If you installed via NPM or Yarn, import utf8Buffer from utf8-buffer:
import * as utf8Buffer from 'utf8-buffer';
let packed = utf8Buffer.pack('\uFFFD');
Or import just what you need:
import {pack} from 'utf8-buffer';
let packed = pack('\uFFFD輸');
Or require:
const utf8Buffer = require('utf8-buffer');
let packed = pack('笠߹~');
Use utf8-buffer.umd.js in the /dist folder of this package:
<script src="./dist/utf8-buffer.umd.js"></script>
<script>
var packed = utf8Buffer.pack('$𒈓eita');
</script>
Or load it from the jsDelivr CDN:
<script src="https://cdn.jsdelivr.net/npm/utf8-buffer"></script>
Or load it from unpkg:
<script src="https://unpkg.com/utf8-buffer"></script>
Only UTF-8 strings with a max of 4 bytes per character are supported. BOM is kept untouched. Invalid characters are replaced with Unicode Character 'REPLACEMENT CHARACTER' (U+FFFD).
Should work in all modern browsers. Cross-browser tests are on the ROADMAP.
/**
* Read a string of UTF-8 characters from a byte buffer.
* @see https://encoding.spec.whatwg.org/#the-encoding
* @see https://stackoverflow.com/a/34926911
* @param {!Uint8Array|!Array<!number>} buffer A byte buffer.
* @param {number=} index The index to read.
* @param {?number=} len The number of bytes to read.
* If len is undefined will read until the end of the buffer.
* @return {string}
*/
export function unpack(buffer, index=0, len=null) {}
/**
* Write a string of UTF-8 characters as a byte buffer.
* @see https://encoding.spec.whatwg.org/#utf-8-encoder
* @param {string} str The string to pack.
* @return {!Uint8Array} The packed string.
*/
export function pack(str) {}
utf8-buffer welcomes all contributions from anyone willing to work in good faith with other contributors and the community. No contribution is too small and all contributions are valued.
See CONTRIBUTING.md for details.
utf8-buffer code should follow the Google JavaScript Style Guide:
https://google.github.io/styleguide/jsguide.html
This project is bound by a code of conduct: The Contributor Covenant, version 1.4, also available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting rocha.rafaelsilva@gmail.com.
Copyright (c) 2018 Rafael da Silva Rocha.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
ES6 module to encode and decode UTF-8 strings.
The npm package utf8-buffer receives a total of 4,092 weekly downloads. As such, utf8-buffer popularity was classified as popular.
We found that utf8-buffer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.