Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

encoding for non-utf8 text? #43

Open
demon386 opened this issue May 24, 2015 · 2 comments
Open

encoding for non-utf8 text? #43

demon386 opened this issue May 24, 2015 · 2 comments
Labels

Comments

@demon386
Copy link

Related to: atom/git-diff#60

My file is GBK encoded. The problem is that for GBK encoded lines, getLineDiffs signals diffs on those lines, even nothing at all is changed.

I tried to use iconv-lite to encode the text to 'GBK' and then decode to 'utf-8' before passing text to getLineDiffs, the problem still exists.

@demon386
Copy link
Author

git-diff uses the following way to invoke getLineDiffs:

getLineDiffs(path, @editor.getText())

When the file is GBK encoded, whether open with UTF-8 or GBK encoding in Atom, pseudo diffs on those GBK lines exist.

Of course, for GBK encoded file one should open it with GBK encoding in Atom (the above UTF-8 is just for debugging). When opening with GBK encoding, I tried to use iconv-lite to encode text:

buffer = iconv.encode(@editor.getText(), 'gbk')
getLineDiffs(path, iconv.decode(buffer, 'utf-8'))

I also tried

buffer = iconv.encode(@editor.getText(), 'gbk')
getLineDiffs(path, buffer.toString())

and

buffer = iconv.encode(@editor.getText(), 'gbk')
getLineDiffs(path, buffer.toString('utf-8'))

None of these work.

@lee-dohm lee-dohm added the bug label May 24, 2015
@versmisse
Copy link

This issue is a duplicate of atom/atom#18224 or atom/git-diff#60

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

No branches or pull requests

3 participants