Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next line separator while generating text with \n #14

Open
artem-bakuta opened this issue Mar 18, 2020 · 1 comment
Open

Next line separator while generating text with \n #14

artem-bakuta opened this issue Mar 18, 2020 · 1 comment

Comments

@artem-bakuta
Copy link

artem-bakuta commented Mar 18, 2020

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

@dariof28
Copy link

dariof28 commented Apr 8, 2020

\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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants