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

Add user callback for handling invalid characters. #53

Open
ashtuchkin opened this issue Apr 28, 2014 · 4 comments
Open

Add user callback for handling invalid characters. #53

ashtuchkin opened this issue Apr 28, 2014 · 4 comments
Labels
Milestone

Comments

@ashtuchkin
Copy link
Owner

Inspired by ICU, something like:

  buf = iconv.encode(str, 'win1251', { invalidCharHandler: function(char) {
    // Here you can either throw exception which will be propagated outside,
    // or return a replacement char.
  });

Probably, some default handlers would also be nice (always throwing, always returning '?', trying to transliterate).

@peakji
Copy link

peakji commented Feb 7, 2017

Any news on this? This would be a great feature to have.

@ashtuchkin
Copy link
Owner Author

I agree, I don't really have time to do it now. The main obstacle is that we need to reimplement all the native Node encodings from scratch to support this feature and it's not easy.

@bpasero
Copy link

bpasero commented Mar 2, 2018

Yes, would also be interested in this. I think this would enable VS Code to implement a dialog like this one:

image

Refs: microsoft/vscode#44505

@lapo-luchini
Copy link

The main obstacle is that we need to reimplement all the native Node encodings from scratch to support this feature and it's not easy.

Maybe re-encoding to original charset and checking that input and regenerated string are equals?
I guess it should be faster than re-implementing that. (but truth be said, I didn't check the code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants