Yuda Prawira
Yuda Prawira

Reputation: 12461

How can I strip out the string like � in php?

How can I vanish out the odd string like � in php?

I already use like html_entity_decode php function but it's still not works.

Upvotes: 0

Views: 123

Answers (4)

Pramod Kumar Sharma
Pramod Kumar Sharma

Reputation: 8012

Try to add these line in your db config file.

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_set_charset('utf8',$con);
mysql_select_db("db_name", $con);


<meta http-equiv="Content-Type" content="text/html; charset=utf8" />

Upvotes: 4

Naveen Kumar
Naveen Kumar

Reputation: 4601

If your content is in ANSI encoding use

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

you can check the encoding of your files using a editor like ( NOTEPAD ++ )

Upvotes: 0

Sibu
Sibu

Reputation: 4617

Try changing your <meta charset to iso-8859-1 like

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

Upvotes: 0

RonLugge
RonLugge

Reputation: 5174

� isn't just one symbol -- it's the symbol used to replace a symbol that your browser can't make sense of. Usually this is caused by encoding issues -- you set the wrong encoding, or someone is using a symbol from a different encoding.

You can't just magically strip it out, because it isn't just one character. Simply put, encoding is one place where you can't just wave a magic wand -- you have to decide on an encoding, and then enforce it.

If you're taking user input, I honestly don't have any clue how to help with the issue. You can check for common causes (curly quotes and dashes as distinct from hyphens are where I run into this the most), and force a manual replace on them, but if a user wants to enter in a badly-encoded character, there's not a lot you can do.

Upvotes: 1

Related Questions