Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support UTF-16 encoding #270

Open
Wernfried opened this issue Mar 3, 2024 · 0 comments
Open

Support UTF-16 encoding #270

Wernfried opened this issue Mar 3, 2024 · 0 comments

Comments

@Wernfried
Copy link

According to W3C Recommendations every XML processor must be able to read UTF-8 and UTF-16 encodings. A XML file encoded in UTF-16

<?xml version="1.0" encoding="UTF-16"?>
<person>Hi Jérôme</person>

throws an error:

C:\nodejs18\node.exe .\demo.js
error at line [1], column [2] Error: Non-whitespace before first tag.
Line: 0
Column: 1
Char: �
    at error (D:\Internet\xml-twig\node_modules\sax\lib\sax.js:652:10)
    at strictFail (D:\Internet\xml-twig\node_modules\sax\lib\sax.js:678:7)
    at beginWhiteSpace (D:\Internet\xml-twig\node_modules\sax\lib\sax.js:952:7)
    at SAXParser.write (D:\Internet\xml-twig\node_modules\sax\lib\sax.js:1007:11)
    at SAXStream.write (D:\Internet\xml-twig\node_modules\sax\lib\sax.js:240:18)
    at ReadStream.ondata (d:\Internet\xml-twig\lib\internal\streams\readable.js:777:22)
    at ReadStream.emit (d:\Internet\xml-twig\lib\events.js:517:28)
    at addChunk (d:\Internet\xml-twig\lib\internal\streams\readable.js:335:12)
    at readableAddChunk (d:\Internet\xml-twig\lib\internal\streams\readable.js:308:9)
    at Readable.push (node:internal/streams/readable:245:10) {stack: 'Error: Non-whitespace before first tag.
Line:….push (node:internal/streams/readable:245:10)', message: 'Non-whitespace before first tag.
Line: 0
Column: 1
Char: �'}
Uncaught TypeError TypeError: Cannot read properties of undefined (reading 'text')
    at <anonymous> (file:///D:/Internet/xml-twig/twig.js:319:30)
    at emit (node:events:517:28)
    at me._parser.<computed> (file:///D:/Internet/xml-twig/node_modules/sax/lib/sax.js:259:17)
    at emit (file:///D:/Internet/xml-twig/node_modules/sax/lib/sax.js:625:35)
    at closeText (file:///D:/Internet/xml-twig/node_modules/sax/lib/sax.js:635:26)
    at error (file:///D:/Internet/xml-twig/node_modules/sax/lib/sax.js:646:5)
    at strictFail (file:///D:/Internet/xml-twig/node_modules/sax/lib/sax.js:678:7)
    at write (file:///D:/Internet/xml-twig/node_modules/sax/lib/sax.js:1036:15)
    at SAXStream.write (file:///D:/Internet/xml-twig/node_modules/sax/lib/sax.js:240:18)
    at ondata (node:internal/streams/readable:777:22)
    at emit (node:events:517:28)
    at addChunk (node:internal/streams/readable:335:12)
    at readableAddChunk (node:internal/streams/readable:308:9)
    at Readable.push (node:internal/streams/readable:245:10)
    at <anonymous> (node:internal/fs/streams:277:14)
    at wrapper (node:fs:684:5)
    at callbackTrampoline (node:internal/async_hooks:130:17)
    --- FSREQCALLBACK ---
    at init (node:internal/inspector_async_hook:25:19)
    at emitInitNative (node:internal/async_hooks:202:43)
    at read (node:fs:687:15)
    at ReadStream._read (node:internal/fs/streams:250:6)
    at Readable.read (node:internal/streams/readable:507:12)
    at maybeReadMore_ (node:internal/streams/readable:661:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)
    --- TickObject ---
    at init (node:internal/inspector_async_hook:25:19)
    at emitInitNative (node:internal/async_hooks:202:43)
    at emitInitScript (node:internal/async_hooks:504:3)
    at nextTick (node:internal/process/task_queues:132:5)
    at maybeReadMore (node:internal/streams/readable:628:13)
    at <anonymous> (node:internal/streams/readable:216:7)
    at onceWrapper (node:events:631:28)
    at emit (node:events:517:28)
    at emitConstructNT (node:internal/streams/destroy:284:10)
    at processTicksAndRejections (node:internal/process/task_queues:81:21)
    --- TickObject ---
    at init (node:internal/inspector_async_hook:25:19)
    at emitInitNative (node:internal/async_hooks:202:43)
    at emitInitScript (node:internal/async_hooks:504:3)
    at nextTick (node:internal/process/task_queues:132:5)
    at onConstruct (node:internal/streams/destroy:270:15)
    at processTicksAndRejections (node:internal/process/task_queues:81:21)
    --- TickObject ---
    at init (node:internal/inspector_async_hook:25:19)
    at emitInitNative (node:internal/async_hooks:202:43)
    at emitInitScript (node:internal/async_hooks:504:3)
    at nextTick (node:internal/process/task_queues:132:5)
    at <anonymous> (node:internal/streams/destroy:276:15)
    at <anonymous> (node:internal/fs/streams:76:9)
    at <anonymous> (node:fs:200:23)
    at callbackTrampoline (node:internal/async_hooks:130:17)
    --- FSREQCALLBACK ---
    at init (node:internal/inspector_async_hook:25:19)
    at emitInitNative (node:internal/async_hooks:202:43)
    at open (node:fs:578:15)
    at _construct (node:internal/fs/streams:71:17)
    at constructNT (node:internal/streams/destroy:275:12)
    at processTicksAndRejections (node:internal/process/task_queues:81:21)
    --- TickObject ---
    at init (node:internal/inspector_async_hook:25:19)
    at emitInitNative (node:internal/async_hooks:202:43)
    at emitInitScript (node:internal/async_hooks:504:3)
    at nextTick (node:internal/process/task_queues:132:5)
    at construct (node:internal/streams/destroy:241:11)
    at Readable (node:internal/streams/readable:214:15)
    at ReadStream (node:internal/fs/streams:214:3)
    at createReadStream (node:fs:3038:10)
    at <anonymous> (file:///D:/Internet/xml-twig/demo.js:6:4)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at executeUserEntryPoint (node:internal/modules/run_main:86:12)
    at <anonymous> (node:internal/main/run_main_module:23:47)
Process exited with code 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant