1
 $fql = 'SELECT name from user where uid = ' . $user;
            $result = $this->facebook->api(array(
                                       'method' => 'fql.query',
                                       'query' => $fql,
                                     ));
var_dump($result);

I select my name from facebook the result is not encoded right Škofja Loka is Å kofja Loka . I have tried to change this utf_encode and utf_decode, but it does not work.

4

1 回答 1

2

"Š"不在 ISO-8859-1 中utf8_decode/utf8_encode,因此从 ISO-8859-1 转换为 ISO-8859-1 的,无法处理它。无论如何,您都不应该使用这些函数,PHP 完全可以使用 UTF-8,无需任何解码或编码。

看起来您所需要的只是 UTF-8 字符集的 http 标头:

<?php
//Before any output
header("Content-Type: text/html; charset=utf-8");

...


 $fql = 'SELECT name from user where uid = ' . $user;
            $result = $this->facebook->api(array(
                                       'method' => 'fql.query',
                                       'query' => $fql,
                                     ));
var_dump($result);
于 2013-01-03T12:40:54.720 回答