-1

Create new database with CHARSET=utf8 and in that i insert currency symbols.
When i try to fetch data with symbol using mysql_fetch_object but it can't display properly.
I already add utf8 charset at header as below.

 &ltmeta http-equiv="Content-Type" content="text/html; charset=utf-8">

But it's not display currency symbol.when i write that symbol on page than it's display but not from database.

Gr Brains
  • 46
  • 1
  • 8
  • [This answer](http://stackoverflow.com/a/5969626/1960712) should help you. – Rene Korss May 13 '15 at 07:06
  • Just do the following: In `php.ini` set `default_charset = "utf-8"` The above will change the default character set for PHP to utf-8. Also change the character set for Apache in `httpd.conf` as below: `AddDefaultCharset UTF-8` Then restart Apache and hopefully your problem will be resolved. – Imran Zahoor May 13 '15 at 07:28

1 Answers1

0

Well I gonna say that UTF8 is quite a pain where-you-think with PHP since it's no natively supported (R.I.P PHP6) and there can be some steps to do so you can "fully" support utf-8 in your content :

1 - First, be sure that the script displaying your content is encoded as UTF-8 (no BOM).

2 - With mysql_*, you can specify

mysql_set_charset('utf8', $link);

with

$link = mysql_connect(...);

3 - It's not UTF-8 related but please switch off mysql_* functions which are deprecated now and that can cause security issues. Have a look at PDO

4 - With SQL, you can specify that you want transactions to be in UTF-8 :

SET NAMES UTF-8

and eventually

SET CHARACTER_SET_RESULTS=UTF-8
Cr3aHal0
  • 809
  • 4
  • 11
  • PHP handles UTF-8 just as well as any other language and has the same issues and most other languages. The only issue with "not natively supported" is that you may have to use some specialised functions when slicing or otherwise manipulating strings, instead of being able to use language primitives like `$string[0]`. – deceze May 13 '15 at 07:13
  • @deceze sorry, was my thought but now I realize it wasn't clear enough, thanks for noticing it :) – Cr3aHal0 May 13 '15 at 07:14
  • Also the encoding in MySQL is called `utf8`, not `UTF-8`. You should also consider `utf8mb4`. – deceze May 13 '15 at 07:15