Do you have experience with PHP, MySQL, HTML, Javascript and live in the St. Louis area? Send me your resume!
The company I work for is looking to hire at least one solid developer.
Things you should know:
This is not an entry-level position, real-world expierience is a must.
Compensation and benefits are fantasitc, just send a note if you're interested or would like more information.
Thanks.
I'm going to start doing video tutorials, I know I enjoy watching and listening to people explain things, I think I'll do some more things in this format.
It seems like I run into this issue for over half of the websites that I work on. The user wants to copy-and-paste their article, document, or whatever from MS Word, into a textarea and save it. The problem is word uses funky quotes, dashes, and other characters. Once it's submitted, PHP gets it and the characters are encoded differently and they display weird.
We've tried several different methods to try to eliminate the problem, but every time I googled for a fix, I never really found anything that worked well.
My boss mentioned that maybe we could fix it on the client-level, so I dove in and found what seems to be a promising fix. It's clean and simple. This function currently only replaces the single and double smart quotes, and then the strange dash character that MS word uses. Feel free to submit for character conversion codes and I'll add it to the function, I'll also add to this once I come across more problems.
function removeMSWordChars(str) { var myReplacements = new Array(); var myCode, intReplacement; myReplacements[8216] = 39; myReplacements[8217] = 39; myReplacements[8220] = 34; myReplacements[8221] = 34; myReplacements[8212] = 45; for(c=0; c<str.length; c++) { var myCode = str.charCodeAt(c); if(myReplacements[myCode] != undefined) { intReplacement = myReplacements[myCode]; str = str.substr(0,c) + String.fromCharCode(intReplacement) + str.substr(c+1); } } return str; }
This is the jQuery that will run the filter on all textareas on your page when you tab away from the textarea (Assumes you have jQuery installed and running on the page.)
$(function(){ $("textarea").blur(function(){ $(this).val(removeMSWordChars(this.value)); }); });
Or if you don't use jQuery and you're a little green to javascript you can do this:
<textarea onBlur="this.value=removeMSWordChars(this.value);" name="a" rows=5 cols=10></textarea>