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

Non latin symbols replaced with ???? after formatting in Windows 10. #22

Closed
Real-Gecko opened this issue May 17, 2022 · 18 comments
Closed

Comments

@Real-Gecko
Copy link

If template contains non ASCII symbols after formatting they're replaced with ? characters. Running djLint directly from command line does not have this issue. So I guess it's somewhere in extension. File encoding is utf-8, OS is Windows 10. In Linux and MacOS everything works as expected.

@monosans
Copy link
Member

monosans commented May 17, 2022

Solution: djlint/djLint#243 (comment).

EDIT: This solution is bad. Update djLint to version 1.1.1 or higher to fix the issue.

@Real-Gecko
Copy link
Author

Yikes it worked :D
Maybe it should be reflected in a README? so that no one ever asks this question again?

@christopherpickering
Copy link
Contributor

christopherpickering commented May 17, 2022

Thats windows for ya 🤣

@Real-Gecko
Copy link
Author

Nah I work on Linux and MacOS, but my colleague are not. I've tired of seeing unformatted templates so :D

@Real-Gecko
Copy link
Author

OK, after enabling utf-8 in winduz some other programs has stopped working as expected. So option was turned off again. So, running from command line works as expected, running through extension does not. Maybe we can tweak something on extension side?
Maybe we can add an option to do formatting inplace and ask editor for reload instead of asking it to replace the text in here?
https://github.com/monosans/djlint-vscode/blob/89073365e968effce95dffd99bbf2dc75d2bb579/src/extension.ts#L247
AFAIK some extensions do that, because I have formatting enabled on save, and when I save the file for some time I see file not being formatted, and then suddenly it changes and is resaved. Noticable when you have a lot of files to save at the same time.

@christopherpickering
Copy link
Contributor

I'll dust of my windows and take a look tomorrow as well. Do you have a small sample code? I'll try w/ 必須 from the other issue otherwise.

@Real-Gecko
Copy link
Author

{% extends 'base.html' %}

{% load i18n django_bootstrap5 %}

{% block content %}
<div class="col-4 offset-4 card">
<div class="card card-body">
<form method="post">
{% csrf_token %}
{% bootstrap_form form %}
<button class="btn btn-primary" type="submit">{% trans "Вход" %}</button>
</form>
</div>
</div>
{% endblock content %}

This one will do I guess notice the {% trans "Вход" %} part.

@monosans
Copy link
Member

Perhaps this will help solve the issue. I'll do it today when I'm at home.

@monosans monosans reopened this May 18, 2022
@christopherpickering
Copy link
Contributor

I tested on my windows > using the output from stdout from djlint does make the "??":

image

It does seem to be from the default windows encoding for cmd.

Git bash it works :D
image

And running click directly works:
image

So it must be something in the process of writing the temp file to reading it in djlint.

I popped open the temp file that stdin was using... it has the dreaded ??

So I followed the ?? upstream in djlint until I got to the stdin and realized that I was reading it as the systems encoding.. which on windows, is not utf8.

After setting it to read as utf8, and also changing windows shell to utf8, it works:
image

Do djlint needs to be updated to read stdin as utf8. Then djlint-vscode will need to be updated to spawn with utf8.
I'll do a new djlint release w/ this update soon.

@monosans
Copy link
Member

@christopherpickering
I see that you have released an update that fixes this issue, cool. Can you please check if I need to make any changes to the extension on my end to fix this problem too. It's just that I don't use Windows so I can't test it.

@monosans
Copy link
Member

AFAIK they use PowerShell as VSCode shell. Don't know what is encoding for this one.

The extension does not launch a shell, but launches Python directly.

@christopherpickering
Copy link
Contributor

Windows is being pretty persistent. The colorize library was also allowing windows to tweak the encoding.. so I need to do another update the djlint to ensure the output is passed to the printer as utf8.

I was able to get it to work in vscode, I'll test a bit more and see if anything needs to be pr'ed.

@christopherpickering
Copy link
Contributor

I published djlint 1.1.1, which seems to fix this 🚀 No changes to djlint-vscode

Kapture 2022-05-18 at 10 56 35
.

@monosans
Copy link
Member

I published djlint 1.1.1, which seems to fix this No changes to djlint-vscode

Amazing! Thank you very much!

I will later write in README.md that djLint version 1.1.1 or higher is required to fix this issue.

@christopherpickering
Copy link
Contributor

No problem, thank you!

@monosans
Copy link
Member

Solution - update djLint to version 1.1.1 or higher.

@Real-Gecko
Copy link
Author

Hey, guys! We've just checked the update on two machines, one with winduz 10 another with 11. In both cases everything works flawlessly. Thanks for your effort! Really appreciated.

@christopherpickering
Copy link
Contributor

Nice!

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

No branches or pull requests

3 participants