a few <tags /> short of a page...
about me

Jonathan Who?

My name is Jonathan Edman and I'm a computer professional in the greater metro Atlanta area. I'm also a vegan, historian, veteran, photographer, musician, platelet donor, Model UN nerd, and a meditating Buddhist Christ follower.

You can find out more about a lot of those things on my About Me page, or check out my professional creds on my resume.

Thanks for visiting. If you have a moment, why don't you shoot me an email and say hey.

Carriage Returns and plain text in PHP

Thursday, August 24, 2006
So, today I was working through a handful of other data / display issues when I found that one of the problems I was having was due to someone cutting and pasting formatted text into a text area. Apparently if you are entering text into a text area and press Return php hides a \r\n (carriage return and new line) in the text value, and if you copy/paste formatted text with carriage returns (or CR/LFs) those \r\n(s) come along for the ride. I only found them after running mysql_real_escape_string() on the text which put another slash in front of each, making them visible. Generally I wouldn't care, but they were causing problems when I was trying to test to see if the text was already in the database. Seems that most of the time php ignores them, but at other times they change the way php evaluates the text (or the value of the text at least, probably because I recently starting using binary values in my comparisons to make those comparisons case sensitive). Given that and the fact that one of the primary goals of this project is to completely separate formatting from content and it became clear that I needed to do something about them. At some point I'm going to try to parse out formatted text so that my users don't have to cut and paste a paragraph at a time into the system, so I was going to have to mess with this eventually anyway...

Anyway, in case anyone else runs into this using a simple str_replace() allowed me to strip them out... and another let me clear out the \t(s) (tabs) which were also hidden, and which didn't get escaped by the mysql_real_escape_string, but which were obvious after I had gotten rid of the \r\n(s).

Why this? Why now? Who are you?

Tuesday, August 22, 2006
I do web development for a small firm in Atlanta, as well as network admin and IT support for my employer, my church, a few of the organizations I'm involved with at school... A good all-around tech guy's job is never really done, not that I think I'm necessarily good, but I am all-around... LoL!! Anyway, as I'm scouring the web trying to find answers to my questions and quandaries I might as well post the interesting bits for posterity... and so I can find them again easily.