3

I have created web-service to get data from database which is in Gujarati(other language).

While i am accessing that URL of web-service in browser i am getting "????????????" instead of real data.

Please help me to get out of it.

Thanks

Vaghani.Rahul
  • 354
  • 1
  • 10

2 Answers2

2

you have to set encoding

ini_set('default_charset', 'utf-8');

on your webservice php file.

Harshal
  • 3,562
  • 9
  • 36
  • 65
  • header('Content-Type: text/html; charset=UTF-8'); sets this already http://stackoverflow.com/questions/8229696/do-i-need-to-set-ini-set-default-charset-utf-8 – Patt Mehta Aug 17 '12 at 12:30
  • 1
    some times the set header does not match the one that you define http://stackoverflow.com/questions/4279282/set-http-header-to-utf-8-php – Harshal Aug 17 '12 at 12:40
  • Thanks Harshal ji for the info :D – Patt Mehta Aug 17 '12 at 12:46
1

Rahul bhai, try to run this script first:

<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

/* change character set to utf8 */
if (!$mysqli->set_charset("utf8")) {
    printf("Error loading character set utf8: %s\n", $mysqli->error);
} else {
    printf("Current character set: %s\n", $mysqli->character_set_name());
}

$mysqli->close();
?

If you can modify the web-service, try to set charset to utf-8 as shown above, or browse stackoverflow for similar questions, where users ask to set charset etc

Patt Mehta
  • 4,110
  • 1
  • 23
  • 47