Right now I am building a expression in a column I am gonna be using later. You see I have a problem where a expression in one of my columns this one:


Gets returned as this.


So my \ is always converted to a ? while clearly I did not clarify that.

Why does this happen?

  • I am using just in field calculator. I am just trying to get the string \gpkg_content.dbf' for a contenation later to construct a filepath. – ThunderSpark Jul 31 '20 at 11:32
  • 8
    You need to use `\\` to get a single backslash. – Jake Jul 31 '20 at 11:44
  • 2
    \a is a bell character which doesn't print well so it comes out as a ? – Ian Turton Jul 31 '20 at 13:18

Your problem is that backslashes in literals are treated as escape sequences, so '\gpkg_content.dbf' being treated as escape sequence \g (which I think is invalid, hence the ?) followed by pkg_content.dbf.

You can use \\ instead of \ to represent an actual backslash. Or you could try /: QGIS on Windows is pretty good at accepting UNIX-style forward-slash rather than backwards-slash filenames, though there are some gaps and it may depend on what you do with the output of the expression later.

Note this all applies to literals specified in ''. A \ is not treated as an escape character if it comes from a field, for instance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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