Line break (n) not working in ios when escaped via StringEscapeUtils.escapeJava
Line break (n) not working in ios when escaped via StringEscapeUtils.escapeJava
I am using compile 'org.apache.commons:commons-lang3:3.4'
library to show emoji in ios app so in my android app to encode string into unicode
i am using this method StringEscapeUtils.escapeJava
its working fine emoji sent via android app showing in ios but when i entered the data which some line break, in ios it shows n
instead of showing text in new line.I tried
compile 'org.apache.commons:commons-lang3:3.4'
unicode
StringEscapeUtils.escapeJava
n
val actualText=editText.text.toString()
val oldText=StringEscapeUtils.escapeJava(actualText).toString()
val newText=oldText.replace("n", "rn")
but its not working.
rn
n
1 Answer
1
After struggling a lot i found the issue.
for these statements:
val actualText=editText.text.toString()
val oldText=StringEscapeUtils.escapeJava(actualText).toString()
val newText=oldText.replace("n", "rn")
This picture(output) will clear everything
after using StringEscapeUtils.escapeJava for old text n not considered as escape sequence character. So i changed replacement statement to:
val reviewText=oldText.replace(StringEscapeUtils.escapeJava("n"), "rn")
and then output is:
after this in ios app instead of showing n it shows text to the new line.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Why
rn
? Apple has long been usingn
as newline.– Eugen Pechanec
Aug 21 at 8:56