0

My code was working well with special chars. I could use Write-Host "é" without any issue.

And then I moved some of my functions to an other PS1 file that I "dot sourced" (using Import-Module does the same), and I got encoding errors : prénom became prénom

I don't understand anything about encoding. VS Code doesn't allow me to change the encoding of a file. It has a parameter to set the default encoding but its defaulted on UTF8 and when I set Windows1252 it changes nothing. If I use Geany to update the encoding to Windows1252 it works... until I save the file again with VS Code.

Everything was working well when all my code was in the same file. Why would creating this second .ps1 file (which I created from the Windows Explorer) be a problem?

Working on Windows 10, in french, with VS Code 1.50.

Thank you in advance

Philipili
  • 11
  • 5
  • 1
    _Windows Powershell_ (`powershell.exe` or integrated console) insists upon `utf8bom` script encoding, unlike _Powershell Core_ (`pwsh.exe`). – JosefZ Oct 08 '20 at 20:30
  • How did you "moved some functions into another PS1 file" - was this manually done with VScode? – Doug Maurer Oct 08 '20 at 21:32
  • Yes, cut/paste from one file to the other. I first created the file from the Windows File Explorer, then opened it in VS Code then cut/paste. – Philipili Oct 09 '20 at 10:57
  • @JosefZ what do you mean by "insists"? The integrated console must be the console used in VS Code to execute the script. So this requires to use the utf8bom encoding ? But why is this integrated console working well if the script is in only one file but not if its separated? – Philipili Oct 09 '20 at 10:59
  • How to change encoding of a file with vscode: https://stackoverflow.com/questions/30082741/change-the-encoding-of-a-file-in-visual-studio-code – Brian Reynolds Oct 10 '20 at 16:19
  • 1
    @BrianReynolds thank you. It's what I was looking for. If I remove the UTF8Bom, it fails on the first double quote char, which is strange. – Philipili Oct 16 '20 at 13:11

0 Answers0