replace in txtFile with mixed Codepage letters utf8 and ANSI
Hello CodePage Experts,
from a translation job i received a translation of VBA GUI-Texts german and spanish GUI Texts. I gave them utf-8 file with german utf8 and received - i think - a mixture with spanisch ANSI. Notepad++ shows the spanisch texts correct with ANSI-View but then the german umlauts are wrong displayed. In utf8 view the spanisch special chars displayed as xF3 xED in a black background box.
How can i search and replace this “xF3” with the search and replace window to “ó”
thanks for help
The problem is that the search dialog expects the file to be properly encoded, and it’s not made to easily search for invalid “characters” to convert them into valid ones.
What I might suggest doing is:
- Save your file and keep a backup copy, so you can easily revert if something goes wrong
- Encoding > ANSI (not Convert to ANSI) so that the bytes are all interpreted as ANSI – and since every byte is a valid ANSI character (though not necessarily the right character), every character you see in the ANSI-interpreted version will be a character you can search for.
- This will make the
óí, but it would change
- This will make the
- Now, in regular expression mode, searching for
ówill find the
ó, and similarly.
- So if you search for the ANSI character and replace with the two-byte sequence below (below, I showed the translation for grave-accent, accute-accent, and the n-tilde characters; you can find an online mapping of ANSI characters to their UTF-8 byte sequences if you have others that you need to fix)
- After all the replacements have been done to change the ANSI characters to UTF-8 byte sequences (so all the ANSI ones look “wrong” now), use Encoding > UTF-8 (again, not the Convert To version), and both your German ones and the Spanish ones should be correct in UTF-8 now.
update: I knew we had previously discussed how to search for invalid bytes. Look at my post from a couple years ago and guy’s reply. So it’s possible to search for invalid bytes when in UTF-8 mode, but the same search can match multiple characters, so it makes it hard to do unique replacements that way. So I think for your description, my multi-step sequence here might be safer for you.
@PeterJones Thank you very much - it works! But you must be careful after some replaces exists new “wrong” Chars in ANSI view with the possibility of also not wanted newly replacements … so the replace all button is dangerous…