使用 node-mssql 时,编码 '_sbcs' 有不正确的 'chars'(必须是 len 128 或 256)
Encoding '_sbcs' has incorrect 'chars' (must be of len 128 or 256) when using node-mssql
我正在使用 node-mysql 来 return 一个简单的数据集,我的数据库 table 只有 2 个 varchar 字段,当我启动我的应用程序来查询数据时,它抛出错误'编码'_sbcs'有不正确的'chars'(必须是len 128或256)'
版本是
*节点:10.15.3
* 节点 mssql: 4.3.5
* SQL 服务器:毫秒 SQL 2014
Error: Encoding '_sbcs' has incorrect 'chars' (must be of len 128 or
256)
at new SBCSCodec (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\iconv-lite\encodings\sbcs-codec.js:14:15)
at Object.getCodec (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\iconv-lite\lib\index.js:100:25)
at Object.getDecoder (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\iconv-lite\lib\index.js:127:23)
at Object.decode (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\iconv-lite\lib\index.js:40:25)
at C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\value-parser.js:379:22
at C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:433:9
at Parser.awaitData (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:144:9)
at Parser.readBuffer (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:430:12)
at readChars (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\value-parser.js:378:19)
at C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\value-parser.js:188:20
at C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:203:9
at Parser.awaitData (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:144:9)
at Parser.readUInt16LE (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:200:12)
at readDataLength (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\value-parser.js:67:27)
at C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\value-parser.js:89:5
at readTextPointerNull (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\value-parser.js:36:5)
at valueParse (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\value-parser.js:88:3)
at next (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\nbcrow-token-parser.js:34:45)
at C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\nbcrow-token-parser.js:53:5
at C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:433:9
at Parser.awaitData (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:144:9)
at Parser.readBuffer (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:430:12)
啊哈,我的问题是由部署工具 'ANT' 引起的,
我使用 ANT 复制 'node-model' 中的文件夹和文件,但是文件 'sbcs-data-generated.js' 的编码从 UTF-8 更改为 ANSI。这导致了问题。
我的解决方案是 --- 在 build.xml 中添加了 'encoding="UTF-8"'
我正在使用 node-mysql 来 return 一个简单的数据集,我的数据库 table 只有 2 个 varchar 字段,当我启动我的应用程序来查询数据时,它抛出错误'编码'_sbcs'有不正确的'chars'(必须是len 128或256)'
版本是
*节点:10.15.3
* 节点 mssql: 4.3.5
* SQL 服务器:毫秒 SQL 2014
Error: Encoding '_sbcs' has incorrect 'chars' (must be of len 128 or 256) at new SBCSCodec (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\iconv-lite\encodings\sbcs-codec.js:14:15) at Object.getCodec (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\iconv-lite\lib\index.js:100:25) at Object.getDecoder (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\iconv-lite\lib\index.js:127:23) at Object.decode (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\iconv-lite\lib\index.js:40:25) at C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\value-parser.js:379:22 at C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:433:9 at Parser.awaitData (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:144:9) at Parser.readBuffer (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:430:12) at readChars (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\value-parser.js:378:19) at C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\value-parser.js:188:20 at C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:203:9 at Parser.awaitData (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:144:9) at Parser.readUInt16LE (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:200:12) at readDataLength (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\value-parser.js:67:27) at C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\value-parser.js:89:5 at readTextPointerNull (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\value-parser.js:36:5) at valueParse (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\value-parser.js:88:3) at next (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\nbcrow-token-parser.js:34:45) at C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\nbcrow-token-parser.js:53:5 at C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:433:9 at Parser.awaitData (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:144:9) at Parser.readBuffer (C:\Users\qpan\Downloads\bzwapp-1.2.0+0272\bzwapps\lib\auth\mssql-auth\node_modules\tedious\lib\token\stream-parser.js:430:12)
啊哈,我的问题是由部署工具 'ANT' 引起的, 我使用 ANT 复制 'node-model' 中的文件夹和文件,但是文件 'sbcs-data-generated.js' 的编码从 UTF-8 更改为 ANSI。这导致了问题。
我的解决方案是 --- 在 build.xml 中添加了 'encoding="UTF-8"'