1

I have this string ”Good morning, Dave”. This string contains two non standard double quotes.

Whenever I try to insert into my database table it is converted to this string %u201DGoodmorning,Dave%u201D

I try to replace this kind of character using preg_replace but they are not helpful.This is what I have tried

1) preg_replace('/[^a-zA-Z0-9_ %\[\]\.\(\)%&-]/s', '', $String);
2) preg_replace('#[^\w()/.%\-&]#',"",$string);

I also Try mysql_real_escape_string, but is is also not helpful. How can I do this?

Yogesh Suthar
  • 30,424
  • 18
  • 72
  • 100
  • 1
    see this http://stackoverflow.com/questions/1401317/remove-non-utf8-characters-from-string – SuVeRa Oct 16 '12 at 12:07

3 Answers3

0

Try this:

urldecode($string);

instead of using the string on it's own.

Stephan
  • 41,764
  • 65
  • 238
  • 329
meza
  • 8,247
  • 1
  • 14
  • 23
0

Have you tried str_replace? format is (item to replace, replace with, string the item is found in.

Jim
  • 1,315
  • 4
  • 17
  • 45
0

I think you were nearly there. 0x201D is the unicode character "RIGHT DOUBLE QUOTATION MARK"

See http://www.fileformat.info/info/unicode/char/201d/index.htm

So you could try...

preg_replace('/\\X201d/', '', $String);
Vicki
  • 668
  • 7
  • 21