今天web建站小编给大家简单介绍一下关于node.js中的encoding
的各种源码!
encoding的源码
const encodingOps = { utf8: { encoding: 'utf8', encodingVal: encodingsMap.utf8, byteLength: byteLengthUtf8, write: (buf, string, offset, len) => buf.utf8Write(string, offset, len), slice: (buf, start, end) => buf.utf8Slice(start, end), indexOf: (buf, val, byteOffset, dir) => indexOfString(buf, val, byteOffset, encodingsMap.utf8, dir) }, ucs2: { encoding: 'ucs2', encodingVal: encodingsMap.utf16le, byteLength: (string) => string.length * 2, write: (buf, string, offset, len) => buf.ucs2Write(string, offset, len), slice: (buf, start, end) => buf.ucs2Slice(start, end), indexOf: (buf, val, byteOffset, dir) => indexOfString(buf, val, byteOffset, encodingsMap.utf16le, dir) }, utf16le: { encoding: 'utf16le', encodingVal: encodingsMap.utf16le, byteLength: (string) => string.length * 2, write: (buf, string, offset, len) => buf.ucs2Write(string, offset, len), slice: (buf, start, end) => buf.ucs2Slice(start, end), indexOf: (buf, val, byteOffset, dir) => indexOfString(buf, val, byteOffset, encodingsMap.utf16le, dir) }, latin1: { encoding: 'latin1', encodingVal: encodingsMap.latin1, byteLength: (string) => string.length, write: (buf, string, offset, len) => buf.latin1Write(string, offset, len), slice: (buf, start, end) => buf.latin1Slice(start, end), indexOf: (buf, val, byteOffset, dir) => indexOfString(buf, val, byteOffset, encodingsMap.latin1, dir) }, ascii: { encoding: 'ascii', encodingVal: encodingsMap.ascii, byteLength: (string) => string.length, write: (buf, string, offset, len) => buf.asciiWrite(string, offset, len), slice: (buf, start, end) => buf.asciiSlice(start, end), indexOf: (buf, val, byteOffset, dir) => indexOfBuffer(buf, fromStringFast(val, encodingOps.ascii), byteOffset, encodingsMap.ascii, dir) }, base64: { encoding: 'base64', encodingVal: encodingsMap.base64, byteLength: (string) => base64ByteLength(string, string.length), write: (buf, string, offset, len) => buf.base64Write(string, offset, len), slice: (buf, start, end) => buf.base64Slice(start, end), indexOf: (buf, val, byteOffset, dir) => indexOfBuffer(buf, fromStringFast(val, encodingOps.base64), byteOffset, encodingsMap.base64, dir) }, hex: { encoding: 'hex', encodingVal: encodingsMap.hex, byteLength: (string) => string.length >>> 1, write: (buf, string, offset, len) => buf.hexWrite(string, offset, len), slice: (buf, start, end) => buf.hexSlice(start, end), indexOf: (buf, val, byteOffset, dir) => indexOfBuffer(buf, fromStringFast(val, encodingOps.hex), byteOffset, encodingsMap.hex, dir) } }; function getEncodingOps(encoding) { encoding += ''; switch (encoding.length) { case 4: if (encoding === 'utf8') return encodingOps.utf8; if (encoding === 'ucs2') return encodingOps.ucs2; encoding = StringPrototypeToLowerCase(encoding); if (encoding === 'utf8') return encodingOps.utf8; if (encoding === 'ucs2') return encodingOps.ucs2; break; case 5: if (encoding === 'utf-8') return encodingOps.utf8; if (encoding === 'ascii') return encodingOps.ascii; if (encoding === 'ucs-2') return encodingOps.ucs2; encoding = StringPrototypeToLowerCase(encoding); if (encoding === 'utf-8') return encodingOps.utf8; if (encoding === 'ascii') return encodingOps.ascii; if (encoding === 'ucs-2') return encodingOps.ucs2; break; case 7: if (encoding === 'utf16le' || StringPrototypeToLowerCase(encoding) === 'utf16le') return encodingOps.utf16le; break; case 8: if (encoding === 'utf-16le' || StringPrototypeToLowerCase(encoding) === 'utf-16le') return encodingOps.utf16le; break; case 6: if (encoding === 'latin1' || encoding === 'binary') return encodingOps.latin1; if (encoding === 'base64') return encodingOps.base64; encoding = StringPrototypeToLowerCase(encoding); if (encoding === 'latin1' || encoding === 'binary') return encodingOps.latin1; if (encoding === 'base64') return encodingOps.base64; break; case 3: if (encoding === 'hex' || StringPrototypeToLowerCase(encoding) === 'hex') return encodingOps.hex; break; } }
vuejs如何实现htmlEncode编码和htmlDecode解码
js如何利用encodeURIComponent对数组进行编码
js方法传参参数有空格报错解决方法(escape、unescape)
上面是“node.js关于encoding的源码介绍”的全面内容,想了解更多关于 nodejs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_3140.html
workflows工作流
- 庭院,彩色玫瑰,云雾笼罩comfyui工作流
- 一个迷人的女人ComfyUI工作流
- 一只由水晶制成的蜂鸟
- 一棵白色心形流苏树comfyui工作流
- 一条色彩斑斓的超现实小孔雀鱼ComfyUI工作流
- 一朵由琥珀制成的孤独美丽的玫瑰
- 半透明的玻璃苹果ComfyUI工作流
- 沙漠里一只红黑相间的蝎子
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!