String syntax escape characters

I have been searching for the "string syntax", specifically the escape character syntax.
I tried putting a newline character in a device string parameter, such as:
Hello World,\r\nMe again.
No joy, it was displayed exactly as written.

More context is needed to provide a clear answer.
Where are you entering a string that needs escaping? How are you displaying it?

I see you're posting in the Rule Machine category, so maybe you're talking about a string input field in the Rule 5.1 user interface? If so, most string inputs just let you put in a literal newline character--i.e., press Return or Enter on your keyboard. (But how different apps or devices handle this may differ...)

1 Like

I kind of get that, however the string variables may need better escape character processing features for that very same reason:
(But how different apps or devices handle this may differ...)

Digging into groovy strings I did find that it provides escape character processing.

I was trying to figure out how the device itself processed a newline character.
I think I will have to modify the driver groovy code in order to do the test and then pass along any useful results...

From a robust programming principle, string escape character processing is good...

Someone can probably give you better help if you give a specific example of what you're looking at (what device and driver, what app, etc.). In general, devices per se don't really deal with this kind of thing, so you are likely looking at how the driver and perhaps app handle such things. A literal newline works in the most common cases I've seen people ask (notification text, setting string variables or files, etc.), but it's hard to say more without knowing what you're actually doing.

Download the Hubitat app