3

We allow user to entry any language in text field and that valu i store in database and we return same language to user when user view in browser.

when i passed "Sant Juliã De Lã²ria" value in database and when i retrieve from database then display like this "Sant Juli�� De L��ria"

How can we display user to same value as user input in text fields

Cœur
  • 37,241
  • 25
  • 195
  • 267
Mehul Dudhat
  • 421
  • 1
  • 7
  • 19
  • 2
    You have a UTF-8/encoding issue. – Funk Forty Niner Jun 20 '14 at 13:11
  • I don't have a specific answer, but I suspect it's going to have to do with the encoding of the column in question. – Chris Thompson Jun 20 '14 at 13:12
  • You are having encoding issue. Keep UTF-8 encoding through out the application. – Subir Kumar Sao Jun 20 '14 at 13:12
  • yes i already encode with UTF-8 is there any issue with fields collation... – Mehul Dudhat Jun 20 '14 at 13:13
  • @MehulDudhat: How would we know? You haven't given us any information about your DB other than the vendor. – T.J. Crowder Jun 20 '14 at 13:14
  • 4
    Obligatory link: [*The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)*](http://www.joelonsoftware.com/articles/Unicode.html) Fundamentally: Make sure the *page* is encoded correctly, the server says what the encoding is, the DB is using the same encoding (or you're intentionally transliterating), etc., etc. – T.J. Crowder Jun 20 '14 at 13:15
  • i am encoding all value with UTF8 and i provide db collation in database utf8mb4_general_ci, is there any issue with this collation. – Mehul Dudhat Jun 20 '14 at 13:48

2 Answers2

0

Use this code before insert

mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
mysql_query($qry);
sismaster
  • 181
  • 1
  • 13
0

If server is in your hands change mysqld configuration (my.cnf file)

[mysql]
default-character-set=utf8
[client]
default-character-set=utf8
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8

then change defaults coalocation in your db, tables

luzik
  • 673
  • 2
  • 7
  • 15