1.0.1 • Published 2 years ago
nv-buf-utf8-boundary v1.0.1
nv-buf-utf8-boundary
- check incomplete utf8 1b 2b 3b 4b in a buffer-tail
install
- npm install nv-buf-utf8-boundary
splitted
usage
const { check} = require("nv-buf-utf8-boundary");
example
> Buffer.from(String.fromCodePoint(65536))
<Buffer f0 90 80 80>
> buf = Buffer.from(String.fromCodePoint(65536))
<Buffer f0 90 80 80>
>
> x.check(buf)
[ 4, [] ]
> buf[3]=buf[2]
128
> buf[2]=buf[1]
144
> buf[1]=buf[0]
240
> buf[0]=97
97
> buf
<Buffer 61 f0 90 80>
> x.check(buf)
[ 1, [ 240, 144, 128 ] ]
>
> buf[3]=buf[2]
144
> buf[2]=buf[1]
240
> buf[1]=buf[0]
97
> buf[0]=98
98
> x.check(buf)
[ 2, [ 240, 144 ] ]
>
> buf
<Buffer 62 61 f0 90>
> buf[3]=buf[2]
240
> buf[2]=buf[1]
97
> buf[1]=buf[0]
98
> buf[0]=99
99
> x.check(buf)
[ 3, [ 240 ] ]
> buf
<Buffer 63 62 61 f0>
>
buf[0] = 96
> x.check(buf)
[ 4, [] ]
>
METHODS
APIS
LICENSE
- ISC
1.0.1
2 years ago