Invalid line break character in textarea data capture breaks my csv extract tools


I have various text area fileds in different forms.

Every now and then someone enters data which creates a funny line break character. It comes out as a rectangular box in SQL Server.

Although the data capture looks ok when viewed in HTML, if i build a CSV extract tool it breaks the record. When the CSV file approaches this line break, it breaks teh CSV extract because it thinks it is a new line.

Is there a way around this but converting the textarea data as it is being captured, or while it is being written to a CSV file?

Who is Participating?
Anthony PerkinsConnect With a Mentor Commented:
>>It is not a standard line break - it appears as a "box" in SQL Server.<<
I suspect you will find that it is a Lf or CrLf.
sample output of the data would help.. then we could probably grab what the character code is....

Could be a mozilla textarea submit... sometimes they output different
Anthony PerkinsCommented:
If it is a line feed consider doing a replace as follows:
Replace(YourTextArea, vbLf, vbNullString)

If it is a carriage return + line feed consider doing a replace as follows:
Replace(YourTextArea, vbCrLf, vbNullString)
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

mrduckersAuthor Commented:
It is not a standard line break - it appears as a "box" in SQL Server.

I'll do a screenshot.
mrduckersAuthor Commented:
Here is the sample.

I can't paste the test here because the boxes dissaper and turn into line breaks.
its to bad you couldnt reproduce the problem cause then you could escape the data into the db or serverHTML encode it... atleast you could find the character that is producing it.
can you try escaping the data on output and see what it does or serverhtmlencode on output?
b0lsc0ttIT ManagerCommented:
You could try sending the output through the code below.  It will look at each character and show the ASCII chracter code in brackets.  In the code strTest is the variable that has the output.

Dim i   ' Code to find character values
For i = 1 to Len(strTest)
   Response.Write Asc(Mid(strTest, i, 1)) & "[" & Mid(strTest, i, 1) & "], "

The suggestion to use Server.HTMLEncode(str) on all data before it is entered in the database is a good idea to try to avoid this.

Let me know how it works or if you have a question.

b0lsc0ttIT ManagerCommented:
One other thought is to look at the browser source (View Source).  There may be a clue to the character in the source that the browser either ignores or interprets wrong.

mrduckersAuthor Commented:
acp: It was, I just did a replace on the field before constructing the csv and it works.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.