1

Possible Duplicate:
UTF-8 all the way through

I want to write a web application in android and use php to connect with mysql.this app is in Persian. when I connect to mysql only with php, I can see data in Persian(therfore my connection to mysql is true) but when i use this php in android app to connect to mysql, I don't get data in Persian. please help.

Community
  • 1
  • 1
sahar
  • 117
  • 3
  • 15
  • You need to set the font for your application , are using latest SDK? i mean 17 , it actually supports RTL languages like Persian , but you need to set your own font too – Mahdi Giveie Nov 26 '12 at 15:55
  • By "font" presumably you mean "character set", right? – tadman Nov 26 '12 at 16:02

1 Answers1

0

your table must charset UTF-8,

before insert & before select you must use this query immediately after connect:

SET CHARACTER SET utf8

for example:

   $m_Handle = mysqli_connect('loaclhost',DATABASEUSERNAME,DATABASEPASSWORD,DATABASENAME) 
    or die ( mysqli_error($m_Handle) ); 

    $sSQL= 'SET CHARACTER SET utf8'; 

    mysqli_query($m_Handle,$sSQL) 
    or die ('Can\'t charset in DataBase'); 

i'm Persian and test it more times...

A1Gard
  • 4,070
  • 4
  • 31
  • 55
  • my php contains this code but don't work! I think i should change the encoding of data received from php in my activity to be accessible in android! is it true? – sahar Nov 26 '12 at 17:13
  • I can see Persian characters with php in my browser. in other words, my php get data from mysql and show them correctly in browser but android can`t show that data correctly. – sahar Nov 26 '12 at 17:24
  • do you send charset meta tag on current page... the computer browsers same smart and can find charset but the mob browser not smart as them. are you use meta tag for current page ? – A1Gard Nov 26 '12 at 19:01
  • I only add " ini_set('default_charset','utf-8'); " in my php and my problem solved. thanks alot. – sahar Nov 27 '12 at 13:41
  • You must send this header before ant thing show to user : header('Content-Type: text/html; charset=utf-8'); and in tag add one meta tag : its worked certainly I hope :) – A1Gard Nov 27 '12 at 14:01