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

setEncoding() fails if encoding is not Node native #4

Open
NuSkooler opened this issue Nov 20, 2015 · 3 comments
Open

setEncoding() fails if encoding is not Node native #4

NuSkooler opened this issue Nov 20, 2015 · 3 comments

Comments

@NuSkooler
Copy link

setEncoding() will throw if encoding is not native to Node. In earlier versions of Node.js, one could expand the supported encodings Node supported (e.g. with iconv-lite). This has changed in 4+.

See https://github.com/ashtuchkin/iconv-lite/wiki/Node-v4-compatibility

@iiegor
Copy link
Owner

iiegor commented Nov 21, 2015

@NuSkooler I created a branch for this, try with https://github.com/iiegor/ptyw.js/tree/fix-set-encoding.

@NuSkooler
Copy link
Author

@iiegor, thanks for the quick response. I tried the fix-set-encoding branch: This prevents the initial crash, but introduces a few new issues:

  1. Garbage output
  2. Keyboard input breaks
  3. Crash when closing:
< events.js:85
<       throw er; // Unhandled 'error' event
<             ^
< Error: read EIO
<     at exports._errnoException (util.js:746:11)
<     at Pipe.onread (net.js:559:26)
program terminated

I was able to fix (1) above by changing some code in the ctor:

// this.socket.setEncoding('utf8');
// changed to this:
this.socket = this.socket.pipe(decodeStream(opt.encoding || 'utf8'));  

Of course, this doesn't solve (2) or (3) and setEncoding() itself remains broken. If you have any ideas I'd love to try them!

@NuSkooler
Copy link
Author

BTW, this workaround functions:

door.on('data', function dataIn(data) {
  self.client.term.write(decode(data, 'cp437')); /* or whatever encoding */
});

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

2 participants