line feed characters for EditText

WAZUMBi

Well-Known Member
Licensed User
Longtime User
OK I am developing a website to cooinside with my My Time Clock app:

http://www.b4x.com/forum/test-my-app/17471-my-time-clock.html#post100051

My question here may or may not be off topic from Basic4Android...

All is well except for one thing:
There is an option in my app where the user can enter notes for the work day. The information is stroed in a database, loads, and displays properly in my app.

I am using the standard nl2br() PHP funtion to convert line feeds to the HTML <br/> tag before sending the information to the web page.

However when I attempt to dynamically load the data from my database via an AJAX script it will not display.

Internet Explorere throws an error:
SCRIPT1015: Unterminated string constant​

Firefox has a similar error.

This only happens to text where a line feed occurs.

Looking at the HTML all the code is properly formatted before AND after the the line feed. (The <br/>). The script just stops after loading the data

So my question is what characters does Android use for line feeds in EditText boxes.

It's not just \n. There is something else there I am not accounting for.
 
Last edited:

WAZUMBi

Well-Known Member
Licensed User
Longtime User
Well if anyones interested this is the solution I came up with:

Android inserts a line feed: chr(10) not \n.

I thought the two were the same but as far as php and javascript are concerned apparantly not.
Am I missing something here. :confused:

Chr(13), \r, \n\r, or any of these combinations didn't work either.


nb2lr() in php does not work.
I had to use str_replace() and replace Chr(10) with a tag.

Then before displaying the string with javascript I has to use str.replace and replace my tag with \n.
 
Upvote 0
Top