Query to find characters added from a word processor

I think some of my users are composing their testimonial in a word processor, and then pasting into my online form. Because every once in a while I’ll get text that doesn’t start new paragraphs correctly. I then pull up the testimonial in my back-end form, click my mouse next to where the next paragraph should have started, and then I have to backspace/delete three times before the text then joins the previous paragraph. At that point I add two hard returns with my keyboard, and then the text goes into a new paragraph as it should. If the text has been entered correctly, then hitting backspace/delete twice on my keyboard will cause the two paragraphs to merge.

All of this has led be to believe that some kind of hidden character is being added, possibly when my users originally compose the text they submit with a word processor. Is there a way to find out what aschii character is causing this? Once I know the character, I should be able to run a query to find all of them in the database so they can be corrected.

I hope this makes sense. Thanks for reading.

Last I knew there are 3 “invisible” newlines used depending on the OS
“\r” “\n” and “\r\n”

So if their editor is using one or the other and you are not making the input uniform, yes, you could see a problem from time to time.

I have a problem on my website where people submit text that apparently is causing problems starting new paragraphs. In the example below, can someone tell me if there is any hidden codes after the word improved? My guess this issue arises when people copy text from their word processor into my online form. I have the Text Cleaner app for Mac, but it doesn’t reveal/show hidden codes, it just removes them if they are there.

Following the Young Living Convention in SLC, Utah I am taking the new Omega Blue, Ningxia Red 2-3 oz per day & the new Digest and Cleanse capsules. I am using the Complete Balance for one meal a day (dinner–and it is so yummy). I also take VitaGreen and Longevity, the new improved.
I started the Trio Cleanse last May because I was taking a time-released Morphine that really slowed my system up; so I have no trouble in that area any longer and it also feels good to know that I am not a host to any parasites.


Are you sanitizing and escaping your data before submitting it to the db?

I clean up the data now, but I didn’t in the early days when some of these entries were submitted. So if I can figure out what “invisible codes” are causing this, I will come up with a PHP MYSQL solution to fix those affected entries.

That’s what I as going to say: More likely OS not word processor. As a Mac user every now and then I come across websites, whenever they regurgitate what I’ve typed for whatever reason, they apparently delete all the new lines I’ve put in, merging all the text into one big paragraph. Very annoying. It’s amazing how many sites do that.

0a \n line feed LF (Unix + OS X)
0d \r carriage return CR (Mac OS9 and less)
0c \f form feed FF

\r\n is Windows’ new line. The 0c \f form feed one isn’t used at all so far as I know, at least very rare.

Most solutions I’ve seen use some kind of “replace()” to make the various inputted text consistent.

eg. to have all "\n"s

$text = str_replace("\r\n", "\n", $text);
$text = str_replace("\r", "\n", $text);

Ok, this is all very helpful. Now I need to find the offending entries in the database so they can be modified. Would this be the best way?

UPDATE testimonies SET testimony = REPLACE(testimony, 0a, “\n”);

Does anyone know of a online tool or a Mac app that would allow me to paste in the offending paragraphs and have it display which codes exist?

Thank you!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.