Content of the XML file changes after copy

I’m trying to copy an xml file in the post installation steps, I’ve tried both copy-item and copy-file and both changes the content of the xml file.

The code I used is:

  1. Copy-Item -Path $file -Destination “$PF\KeePass Password Safe 2\KeePass.config.xml” -Force

  2. Copy-File -Path $file -Destination “$PF\KeePass Password Safe 2\KeePass.config.xml”

bellow is the snap before and after copy.
before-
(Dérivé du mot de passe précédent)
after-
(D�riv� du mot de passe pr�c�dent)

any solution or suggestions …?

Looks like the new file got a different Encoding but I don’t think that is possible if you just copy the file (assuming the source file is correctly encoded ofc). This could however happen if you modified the contents of xml file and didn’t save it with the correct encoding.

2 Likes

If JFP is correct:

  • Get Notepad++

  • open the good file (the one without the weird characters)

  • note the encoding at bottom right
    image

  • Then open the Newer file

  • convert to the matching encoding of the first file
    image

  • Save the Newer file

2 Likes