|
-
Feb 14th, 2008, 11:54 AM
#1
Thread Starter
Hyperactive Member
str_replace to find and fix weird quotes
How would I go about replacing weird quotes?
ex: ‘,’, “, and ”.
Code:
$vCLEANED = str_replace("'", "\'", $vSlashes);
$vCLEANED = str_replace('"', '\"', $vCLEANED);
$vCLEANED = str_replace("’", "\'", $vCLEANED);
First two lines work, third one does not.
These are apparently latin extended A and B
http://www.ascii.cl/htmlcodes.htm (bottom)
-
Feb 15th, 2008, 03:43 AM
#2
Re: str_replace to find and fix weird quotes
Have a look at addslashes(); http://uk.php.net/add_slashes
If this data is going in a database though I suggest you use an abstraction layer such as Pear::MDB or PDO as they will automatically handle the escaping of data for you.
[Fixed errant smiley — Mod]
-
Feb 15th, 2008, 09:39 AM
#3
Thread Starter
Hyperactive Member
Re: str_replace to find and fix weird quotes
 Originally Posted by visualAd
Have a look at addslashes(); http://uk.php.net/add_slashes
If this data is going in a database though I suggest you use an abstraction layer such as Pear::MDB or PDO as they will automatically handle the escaping of data for you.
[Fixed errant smiley — Mod]
add_slashes gives me the same issue.
I need some voodoo which lets me detect them so I can replace them with a real '.
The DB is a mysql, and its for a internal intranet site were securty is not very high.
edit: and
Code:
$vCLEANED = str_replace(chr(402), "\'", $vCLEANED);
also does not work.
edit2: and to top of all the fun... I had two scripts. One of them was working, the other was not. Then I merged them (but without really touching the first) and now they both dont work....
Last edited by Zeratulsdomain; Feb 15th, 2008 at 10:03 AM.
-
Feb 15th, 2008, 10:58 AM
#4
Re: str_replace to find and fix weird quotes
I understand what you are saying now. You need to find the character code when it reaches your script as a different character encoding on the client side can yeild different results on the server side.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|