-1

Strange character is shown as � in while my page encoding is in utf-8 but if encoding is ISO-8859-1 than it works fine. I am storing data in mysql database with column encoding utf-8 and connection encoding utf-8. all other characters such as ß are shown properly and stored same in database.

Can some one explain which character is this and how to remove it?

Thanks.

Vivek Vaghela
  • 1,075
  • 9
  • 16
  • What is your html page encoding set to? Try setting it to utf-8, for example, with `meta` tag: ` ` – Aleks G Feb 16 '12 at 16:11
  • To less information. Where comes the string from? Did you try to watch at the byte representation, e.g. with a hex editor? Did you try to output the character code with ord()? – ckruse Feb 16 '12 at 16:13

2 Answers2

1

The U+FFFD is a replacement character used to replace an unknown or unprintable character. Basically, this means you are trying to show an unprintable character.

Maybe this will offer some guidance on how to proceed: How to handle user input of invalid UTF-8 characters?

Community
  • 1
  • 1
Jeremy Harris
  • 24,318
  • 13
  • 79
  • 133
  • Thanks. The link you provided is very useful for me. Just used `iconv('UTF-8', 'UTF-8//IGNORE', $str);` function to remove unkown UTF-8 character. – Vivek Vaghela Feb 16 '12 at 17:24
0

Can some one explain which character is this

Since you only showed us the "Unknown character" character instead of the one that worked, that would be tricky.

how to remove it

Don't remove arbitrary data. Pick the character encoding you are using and stick to it. If you are using UTF-8, then use UTF-8 throughout. Don't switch between treating UTF-8 as UTF-8 and treating it as ISO-8859-1, that way lies madness.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335