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

Auto detect ANSI encoding #7048

Closed
swaner opened this issue May 31, 2016 · 11 comments
Closed

Auto detect ANSI encoding #7048

swaner opened this issue May 31, 2016 · 11 comments
Labels
*duplicate Issue identified as a duplicate of another issue(s) feature-request Request for new features or functionality file-explorer Explorer widget issues
Milestone

Comments

@swaner
Copy link

swaner commented May 31, 2016

  • VSCode Version:
    1.1.1
  • OS Version:
    Win 10

Steps to Reproduce:

  1. Create a new file in notepad, save it as ANSI (on my machine Ansi = Windows-1252)
  2. Open the file in vs code

Result: VSCode assumes UTF-8 and the file is corrupted. Sublime-text has no problem recognizing Windows-1252.

@bpasero
Copy link
Member

bpasero commented May 31, 2016

@swaner we do not have encoding detection so you need to either configure the encoding globally or per workspace or switch it from the status bar picker.

@bpasero bpasero changed the title VSCode does not recognize ANSI encoding Auto detect ANSI encoding May 31, 2016
@bpasero bpasero added feature-request Request for new features or functionality file-explorer Explorer widget issues labels May 31, 2016
@bpasero bpasero added this to the Backlog milestone May 31, 2016
@MantvydasD
Copy link

MantvydasD commented Jul 12, 2016

I support this issue. I just had a deployment using a script which had ® character inside it and I then edited with Code. And ooh, how the script failed and brought down the system. Simple editors handle ANSI files simply, and Code doesn't. That's a shame.

I attach a sample file to test. When I open this file with Code I see � instead of ®, it should leave ® alone. And I tried to change encoding to ANSI, and I couldn't find it among Change File Encoding. Windows 1252 should explicitly say it's ANSI. And Code should automatically understand it's such.

Character ®.txt

@JoV5
Copy link

JoV5 commented Jul 20, 2016

+1

@g3o2
Copy link

g3o2 commented Sep 16, 2016

Less powerful alternatives for handling this issue in the short run:

  • use the problems or errors counter to signal the presence of � or any unrecognised characters;
  • upon opening a file containing unrecognised characters, issue a question dialog suggesting Reopen with encoding or Continue. At least this will help prevent accidental overwriting;

Of course encoding detection would much more powerful.

@buzzzzer
Copy link

It is better to add onOpenFile setEnconding to api extentions...

@regs01
Copy link

regs01 commented Dec 15, 2016

I have UTF8 files and I have Windows 1251 files. I can't change it globally to Windows 1251. So every time i open them i have to reopen them. Why, at least, not to save desired encoding per file? If once i opened it in Win1251, open it in Win1251 any time else, unless i reopen or resave it manually as other encoding?

And it has western codepages stuck at the top of codepages list rather than local codepages.

@llucassantoss
Copy link

Hi,
For ANSI files, use Western (Windows 1252).

@bpasero
Copy link
Member

bpasero commented Dec 18, 2016

#5388

@bpasero bpasero closed this as completed Dec 18, 2016
@bpasero bpasero added the *duplicate Issue identified as a duplicate of another issue(s) label Dec 18, 2016
@mauriciovirtual
Copy link

mauriciovirtual commented Dec 30, 2016

Hi, a friend of mine found a workaround for this "ansi autodetect" problem:

  • Under "preferences / user settings" we find "files.encoding"
  • after that we choose "edit" to send it to right
  • manually we past the line 3 times, like below:
    "files.encoding": "utf8bom",
    "files.encoding": "utf8",
    "files.encoding":"windows1252"
  • ignore warnings about duplicate object key, save file, close vsCode, open again and voila, now I can open UTF8 or ANSI encoded files with no problem and no need to "reload with encode".
    We dont know why it works, but it just works fine on vsCode 1.8.1

Credits to my friend Marcos Cosmoski Filho.

@Hyperdingo
Copy link

This setting has been added: files.autoGuessEncoding

Will hopefully be true as default soon; #23417

@QtRoS
Copy link

QtRoS commented Oct 30, 2017

Why only CP1252? I want this for CP1251 too... Someone else will want this for another encoding and so on. I think that you should pick local encoding of this machine. What do you think of it?

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) feature-request Request for new features or functionality file-explorer Explorer widget issues
Projects
None yet
Development

No branches or pull requests