Unknown String Operator \ new to me

Unknown string operator, new to me.

Var a As String = \"Bokm\xC3\xA5l"

The “\” translate the escaped string to “Bokmål”

Where can i found more information about “\”

so, i can translate a escaped String to an unescaped string?
How can i translate back (unescaped->escaped??


This is new to me too.

@Geoff_Perlman is there a documentation page for assigning a string with backslash character ?

Well I’ll be, I’ve never seen that either, and now I wonder what else you can do with this.

Holy smokes, it will accept multi-line strings!

var s as string = \"this
that" // Works!

All those years writing code :man_facepalming: like this:

var s as string = "like" + Endofline + _

The IDE doesn’t know what to do with that so it isn’t formatted properly, but that’s a minor quibble.

More discoveries…

"" does not represent a ". Instead you have to use the code \x22.

I can’t see how to represent characters beyond a single-byte code. For example, \xA764 should give me “ꝥ” but does not.

It was actually an accident :laughing:

I think this work only with UTF-8 codes. \xC3\xBE works.

This was only ever supposed to be for the IDE to parse text projects, so you’re limited to the same things you’ll find hacking the text format.

I would not consider this safe to use in our own code unless Xojo were to document every little thing about it.

Right you are.

I have, in my constants when saved as text. But thought that only the IDE / Compiler accepted that for loading but at the programming level it wasn’t acceptable and would end as an error. That’s a kind of C string escape sequence. I discovered it when I pasted a multiline string ending lines with chr(10) presenting malfunction and in the code I’ve saw things as “Line 1\rLine 2\r” showing that the IDE changed my new-lines by carriage-returns. And yes, \r, \n works too.

When a string is prefixed with the \ character, Xojo treats the string as a C String Literal, all standard String Literal rules apply. This is currently undocumented but I’ll add something about it now.

1 Like

That seems like an unwise gut-reaction choice since the newline ability breaks syntax coloring and is very obviously not supported by the IDE. Fix the IDE support before making official documentation.

1 Like

Disagree. It exists, it works, and the compiler allows it, so document it now and fix the visual display later.


Sorry, no, \xXX represents bytes so \xXX\xYY would insert two bytes, not the code XXYY. You’d have to figure out the bytes behind that encoding and insert those manually, and that’s not great.

But this is a minor challenge and, after the feature is documented, I’ll start a ticket to get support for \uXXXX and \u{YYYY}.

Well it exists, and has existed since the time when there was actually a compiler engineer, solely for the IDE to deal with encoding things in text projects. I’d rather see Xojo flesh out features and implement them completely. This trend of rushing to release and document it as “incomplete” is not what I consider quality software.


Integer division ?: c = a \ b


Do not search it at ‘\’ but at Integer Division…:japanese_ogre:

1 Like

I wouldn’t use it in code, see https://tracker.xojo.com/xojoinc/xojo/-/issues/73088

All those years writing code :man_facepalming: like this:
var s as string = “like” + Endofline + _

And years from now you will still understand what that code is doing.

But if you take advantage of:
var s as string = "this
that" // Works!
Sometime in the future, something might be moved - and extra space, an extra Return, and s will be different and I’m guessing it will be a heck of a problem to track down.