gen_lang icon indicating copy to clipboard operation
gen_lang copied to clipboard

Next line separator while generating text with \n

Open artem-bakuta opened this issue 4 years ago • 1 comments

Hi, I need to have need paragraph in my string line, so I'm writing :

'Firstly enter your email and password.\nThis is not difficult )'

but it's generated as

'Firstly enter your email and password. This is not difficult )'

it's not difficult to correct it every time, but if it'll be more then 100 strings with same format, it's gonna to be a trouble

artem-bakuta avatar Mar 18 '20 08:03 artem-bakuta

\n is an escape sequence. If you insert it inside a string of course the string will break a new line when printed.

var message = "This string will \nbreakline";
print(message);

will output

This String
will break line

If you need to print the \n instead of being converted to a new line you need to escape the \

var message = "Using \\n you can break a line";
print(message);

will output

Using \n you can break a line

If you simply want to avoid line break you should sanitaze the source string removing all the \n occurrences before generating the message

dariof28 avatar Apr 08 '20 10:04 dariof28