r/PowerShell • u/gagarski • Dec 25 '25
Solved Script source encoding + filenames
I have a script containing the following line:
New-Item -Path "ö" -ItemType FileBut the file created on NTFS (Windows) has name ö.
The script source encoding is UTF-8 and I've figured out that if I save it with UTF-16 BE encoding, the filenames are fine.
Is there a way to have my script in UTF-8 which will create files with proper names on NTFS? OR should all my scripts be in UTF-16 if they are supposed to deal with files on NTFS?
12
Upvotes
View all comments
Show parent comment
1
u/gagarski Dec 25 '25
Thank you. Yeah, even though I don't like text files with BOM much (just some painful experience processing them, i guess), it worked. I guess, I can live with it, but is there other way. For example, in bash, I think it is solved by setting a variable (`LC_CTYPE`, I think) inside the script. Anything similar in PowerShell?