package
Find the length of a UTF-8 glyph by its first byte
npm install high-orderGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Calculates the number of bytes in a UTF-8 glyph given just its first byte
const highOrder = require('high-order');
console.log(highOrder(0xC0)); //-> 2
console.log(highOrder(0x01)); //-> 1
// continuation byte
console.log(highOrder(0x81)); //-> 0
console.log(Buffer('🦄')[0])); //-> 4Licensed under the MIT License. You can find a copy of it in LICENSE.