"symfony new project-name" command generates files in ISO-9958-1 encoding

Viewed 131

Can somebody tell me why

symfony new project-name --full

generates files in ISO-8859-1 encoding? As I found out right now files are not in UTF-8 encoding. Why is it so and how can I change it to UTF-8? How to ensure that commands like make:form will generate UTF-8 files?

I am on Windows 10.

1 Answers

This is very likely your text editor getting confused or "assuming" an incorrect encoding..

symfony new project-name --full simply creates the project using composer. Specifically it calls:

composer create-project symfony/website-skeleton

Which in turn calls git clone, and that's it.

Files are not really "generated", but simply cloned from the appropriate Git repository. And Git will straight retrieve the files as they exist in the repository, without applying any kind of transformation.

So files will use whatever encoding they have in the original repositories. Which, as far as I can see and as much as it matters... it already is UTF-8.

But more importantly, almost all —with very few exceptions— files only include characters in the ASCII range... and since UTF-8 is a superset of ASCII, files without characters outside the ASCII range are undistinguishable as UTF-8 or ISO-8859-1.

On top of that, the actual encoding for the files is largely irrelevant, apart from very specific places (e.g. hard-coded strings that will be used as output).

My guess is that in the absence of special characters or BOM, your text editor is defaulting to show the files as if they were "encoded" in the default encoding for the editor, because if you add any characters beyond the ASCII range, those will be encoded using ISO-8859-1.

The solution is to change the settings of whatever code editor you use so it defaults to UTF-8.

Related