-
Notifications
You must be signed in to change notification settings - Fork 510
French characters are not displayed correctly when debugging #1680
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
Comments
@neothoms thanks for reporting this! The command you are running is provided by VSCode and it just pastes the path of the open file into the active terminal followed by an "enter" key, so it is likely that the issue is on the VSCode side: looks related to this issue microsoft/vscode#31366 |
Seems to be affecting variables definition too... 2- When I open the same fine in ISE, I get this: 3- I then correct/save/run the same file in ISE with this result: 4- Finally, back in vscode,it displays like this, but runs ok !!! Hope this helps PSVersion 5.1.17763.134 |
This is an encoding problem that occurs with file handling between VSCode and the ISE. Please see #1351 and #1306 (comment). There's not much we can do from the extension's perspective -- the solution lies in ensuring you have VSCode, the ISE and PowerShell all configured to use UTF-8. The encoding problems you're seeing are (for example) due to the You need to set PowerShell's encoding to UTF-8, or VSCode's to ISO-8859-1, and make sure the ISE is also configured to do the same. The encoding settings of all your tools need to be set to the same encoding. Because PowerShell defaults to CP-1252 for things like this, but VSCode defaults to UTF-8, you will need to make a conscious choice as to how you encode your scripts in source control and how you configure the encoding in your editors and PowerShell. If they get out of sync, they may all try to re-encode files and cause problems again. |
I understand your points. Thanks in advance |
That's probably because all the required characters lie within the CP-1252 codepage. The problem now is that the upper half of CP-1252 characters are incompatible with UTF-8. It looks like you are creating the PowerShell files as UTF-8, but PowerShell is trying to read them as CP-1252. So you need to change the encoding in the integrated terminal (which is just a matter of setting the .NET settings as in normal PowerShell). This is probably best done in your profile. For setting editor encodings, see #1308 (comment). |
It sounds like it might be helpful for us to summarise this in a document. But I should emphasise that the encoding problems stem from having editor, PowerShell and source control settings out of sync. There's nothing the extension can really magically do without being opinionated (and therefore breaking people). |
coz usually if I follow the following workflow the french characters are always displayed ok at every step, even in source control
thanks for the very appreciated enlightenment and have a great day |
I totally agree :) |
I think the only caveat is that you need to ensure that ISE is configured to use UTF-8. The annoying part in VSCode is that because it's client/server, you need to configure both VSCode and the Integrated Terminal separately.
Thank you! Let us know if you continue to experience issues. Encoding in PowerShell is a problem with no simple solutions, but we are definitely interested in feedback to make it all work as best we can. |
Unfortunately, I can't do that. If I use UTF8 in ISE/VSCODE/NPP for example, all hell breaks loose at execution: variables contaning accented characters break, display strings too. The only way it works flawlessy at each step of the way on my computers/vms set to Windows english plus french lang pack is if I create the powershell scripts in "UTF8 with BOM" (default behavior in ISE, manual config in NPP) |
That's because without the BOM PowerShell defaults to CP-1252. If you set PowerShell to use UTF-8, that shouldn't happen: $OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding In PowerShell 6+, it should default to UTF-8 anyway and you won't hit any of these problems out of the box. |
I'll give this a try. If I end up not having to ask the customers to change their default powershell behavior, that would be great... where should I put this line? in my script, in the powershell profile? Thanks a zillllion ;-) |
Add this to your VSCode settings |
Thanks alot Sydney, will try this asap. :) Now, I'd also like to try the solution provided by @rjmholt but can't seem to make it work: I pated the line in a test script created in vscode in UTF-8, but I get the same errors and display gibberish :( |
The best place is probably in your profile. Otherwise, just execute it in your integrated terminal session. Let use know if that doesn't work though. |
Hi ! all tests are done in a slim vm running windows 10 ent 1809 english + french langpack + chocalatey packages: PS C:\src\tst\french> choco list --localonly PS C:\src\tst\french> $PSVersionTable Name Value PSVersion 5.1.17763.134 |
System Details Output
Issue Description
I am experiencing a problem with French characters wich are not correctly reproduced on VS Integrated console but it may also apears with any special characters from any language.
Expected Behaviour
When I type the following command directly in the console everything is displayed correctly.
write-host "---- These are french characters : âà ç éèë ïï and they are not correctly displayed ----"
Actual Behaviour
But if I use the powershell extension and type the same command in a .ps1 file encoded in UTF8 I have this incorrect result :
Attached Logs
Follow the instructions in the troubleshooting docs
about capturing and sending logs.
The text was updated successfully, but these errors were encountered: