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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate components with UTF-8 encoding #13908

felipedsc opened this Issue Mar 13, 2019 · 2 comments


None yet
2 participants
Copy link

felipedsc commented Mar 13, 2019

馃殌 Feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [x] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc


Files are not generated with utf-8 encoding.
There was an issue about that opened in 2016 which was closed without providing a solution:

When you generate a new component (ng g c test), the files are created using the encoding "Western European (Windows) - Codepage 1252" which is Windows' default .

Many people (including me) haven't faced this problem because Visual Code forces your file encoding to UTF-8. As one of our team members wants to use Visual Studio instead of Visual Code, it keeps the original encoding I mentioned previously, causing some problems on the template.

It seems that we cannot change windows default encoding and as I couldn't find any configuration or option (on "ng g c") to force generate UTF-8 files, I'm creating this request.

Describe the solution you'd like

I believe a configuration (angular.json?) would be the best solution.

Describe alternatives you've considered

Re-saving each file; using vscode; installing an extension for visual studio to force utf-8 also should work...


This comment has been minimized.

Copy link

alan-agius4 commented Mar 14, 2019

Hi, I am not sure how to replicate the problem you are facing.

Under the hood, the CLI/devkit uses Node JS writeFile method to write files and we are using the default encoding which is UTF-8.

However, when no special characters are found Node JS will set the charset to ascii and not utf-8.

Visual Studio seems not to be respecting the .editorconfig settings. Which might be related to the comment posted here: #2077 (comment)


This comment has been minimized.

Copy link

felipedsc commented Mar 18, 2019

hey @alan-agius4, considering that changing the encoding when there is no special characters is an expected behaviour, it is acceptable that it may be not CLI's responsibility.
We could solve the problem with .editorconfig file as you mentioned. There was no .editorconfig in his project, so we've created it on project's root, which initially didn't solve the problem - I believe that it didn't work due to the choosen archicture: the front-end and back-end are not separated into different solutions. As the front-end is a project inside a "back-end solution", so we've moved it to front-end's project specifically and after saving the file, it had the encoding changed to utf-8!

Thanks for making it clear for us, and, as I said before, I understand that it may not be Angular/CLI's responsibility. Sorry for any inconvenience caused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.