Page 1 of 1

backslash escaped in Option menu

Posted: Wed Mar 06, 2019 3:09 pm
by kaveh1000
Please see attached sample stack.

It seems the backslash is used as an escape character, not a literal "\" in option menu content. Here is what the menu content entry is and what is seen in the menu choice:

Code: Select all

\text  > "text"
\ text > " text"
\\text > "\text"
Is this expected behaviour? I hope not!

Re: backslash escaped in Option menu

Posted: Wed Mar 06, 2019 3:19 pm
by Klaus
Hi kaveh1000,

yes this is exspected and correct behavior!

\text -> Nothing to escape so we see -> "text"
\ text -> The SPACE is escaped although not neccessary -> " text"
test -> same as above without the backslash -> " test"***
\\text -> the second Backslash is escaped and we see only one backslash in the menu -> "\text"

***HTML will remove the space at the beginning of the line unfortunately.

What do you want to achieve?


Best

Klaus

Re: backslash escaped in Option menu

Posted: Wed Mar 06, 2019 3:26 pm
by bogs
What Klaus said. The only thing I could add is that this is *not* just related to the '\' character in the menu, but a few others as well, such as '&' (ampersand).

When you need to see one of these types of characters in the menu, you need to 'double it up' as Klaus points out, so if you wanted to see an &Menuitem in the menu, like for instance, a menuItem [Close & Save], you'd have to have it written like [Close && Save].

That should make it clear as mud :P
Selection_003.png
Close and save...

Re: backslash escaped in Option menu

Posted: Wed Mar 06, 2019 3:35 pm
by kaveh1000
Thank you both. So what is the exact rule for rendering the content? Klaus mentioned HTML, but it is not setting the content as HTMLtext. When I put <b>text</b> I see the same text rendered. And why not just put the text verbatim without escaping?

Sorry if it is elementary questions. I can achieve what I want by escaping the chars, but just want to check the rule...

Re: backslash escaped in Option menu

Posted: Wed Mar 06, 2019 3:49 pm
by Klaus
I meant that this HTML Page ate the SPACE at the beginning of this line:
...
test -> same as above without the backslash -> " test"
...

Some basics:
https://en.wikipedia.org/wiki/Escape_character

Re: backslash escaped in Option menu

Posted: Wed Mar 06, 2019 4:05 pm
by kaveh1000
Thank you so much all. I have an application where I need to auto-populate menus with text that has weird characters, including "\". So I will just have a function that converts these before populating the menu text.