You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For compatibility reasons, I use PowerShell v5.1 scripts, which by
default use the ANSI/Windows 1252 character encoding.
dnGrep does not detect these files using ANSI/W1252 and, when
making text substitutions, the files are saved using UTF-8.
For reference, WinMerge correctly detects the character encoding
in PowerShell files. It identifies .ps1 files when they are encoded in
ANSI (PS v5.1) and in UTF8 (PS v7).
Is it possible to implement a way to override character encoding
detection for file types?
The automatic encoding detection returns Western European (ISO) cp28591 for the ANSI file. I think that is reasonable given the characters in the file. If it had contained the Euro sign (€), Trademark symbol (™), smart quotes (“ ”), curly apostrophes (‘ ’), en-dash (–), or em-dash (—), it would have returned cp1252. I didn't write the encoding detector, it is a library call. I don't know why it would prefer cp28591 over cp1252.
The file is shown correctly in the results tree and preview window with cp28591 and with cp1252.
Yes, there is a bug in the Replace preview code. It is not setting the encoding correctly when reading in the modified data for preview. But from what I see, the code that writes the output file (which is separate from the preview) is using the correct encoding and the output file is the same encoding as the input file.
Activity
doug24 commentedon Feb 26, 2026
No, not by file type. You can override it for a search so all files found in the search would use the encoding you pick.
Can you post a file here that has this problem? I'd like to see what is happening.
MBV21 commentedon Feb 26, 2026
Sure thing.
PS1.zip
MBV21 commentedon Feb 26, 2026
Additional information.
doug24 commentedon Feb 26, 2026
The automatic encoding detection returns Western European (ISO) cp28591 for the ANSI file. I think that is reasonable given the characters in the file. If it had contained the Euro sign (€), Trademark symbol (™), smart quotes (“ ”), curly apostrophes (‘ ’), en-dash (–), or em-dash (—), it would have returned cp1252. I didn't write the encoding detector, it is a library call. I don't know why it would prefer cp28591 over cp1252.
The file is shown correctly in the results tree and preview window with cp28591 and with cp1252.
Yes, there is a bug in the Replace preview code. It is not setting the encoding correctly when reading in the modified data for preview. But from what I see, the code that writes the output file (which is separate from the preview) is using the correct encoding and the output file is the same encoding as the input file.
MBV21 commentedon Feb 27, 2026
Thank you.
dnGrep is an amazing tool.
doug24 commentedon Mar 11, 2026
Fix is included in the v4.7.10 release