I work with languages that use Unicode symbols in their placenames. I often receive layers with labels that display incorrectly, but they are messed up in the same way all the time eg: the place name shows Ñ but it should read K̲, or ñ should be k̲.

I have the code for a single find and replace, but I would like to batch find and replace all the problem letters at once. How do I string together several letter replacements?

This is the code I have to replace a single letter:


But I would like it to fix all of these values at once:


I also need to replace a regular apostrophe ' (U+0027) in the middle of the word word with a right single quotation mark (U+2019) style apostrophe. This is my code that doesn't work:

  • 5
    wouldn't it be better to fix the imported files encoding so it is not broken?
    – Ian Turton
    Jun 26, 2020 at 7:35
  • I don't know enough about these things to know how the file encoding gets broken. It has happened to a lot of shapefiles I get. They were all made a decade or so ago, and for whatever the reason, the attribute tables have altered unicode letters. It might be an ESRI to QGIS thing, but I don't have a way to test that.
    – CDEdwards
    Jun 26, 2020 at 17:27
  • 1
    It just means that the default encoding is set wrong. Experiment with one of the shapefiles until it works and then set the default
    – Ian Turton
    Jun 26, 2020 at 18:27
  • I have since learned that the files are built to be used with a special font that was made to display/translate the unicode letters for this language (they show properly as labels when I use this particular font). But it is a font that does not display well for cartography (tall and thin with big serifs). So I would prefer to just quickly correct the formatting of the letters in the attribute table so that I can use any unicode font.
    – CDEdwards
    Jun 26, 2020 at 19:21

2 Answers 2


You can use the map variant of replace, where the map is a series of key-value, the key being the string being searched for and the value being the replacement string


You can replace a regular apostrophe ' (U+0027) in the middle of the word word with a right single quotation mark (U+2019) style apostrophe using this expression:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.