Skip to content

Generate components with UTF-8 encoding #13908

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

Closed
felipedsc opened this issue Mar 13, 2019 · 3 comments
Closed

Generate components with UTF-8 encoding #13908

felipedsc opened this issue Mar 13, 2019 · 3 comments
Labels
needs: more info Reporter must clarify the issue

Comments

@felipedsc
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

Description

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

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...

@alan-agius4
Copy link
Collaborator

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)

@alan-agius4 alan-agius4 added the needs: more info Reporter must clarify the issue label Mar 14, 2019
@felipedsc
Copy link
Author

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.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: more info Reporter must clarify the issue
Projects
None yet
Development

No branches or pull requests

2 participants