English 中文(简体)
• 把一名JSON变成一个UTF-8
原标题:Convert a JSON into a UTF-8 string

我想把一名JSON物体变成一个扼杀物。 当我使用<代码>json_encode。 我听到了一段话,但都收到过他的信。 我想将其改为UTF-8。 换言之,我希望看到这些特点。 我如何这样做?

问题回答

我正在使用<代码>json_encode储存MySQL油田的阿拉伯文特征等数据。

它将在数据库中储存阿拉伯特性,如HEX:

u0644 u063a

是不正确的。 您必须确保您将<代码>json_encode与mysql_e爱因_string()

这将确保数据载于MySQL:

u0644u063a

Then, when you use json_decode, it converts the HEX strings into UTF-8 and is output correctly.

您可尝试通过<编码>json_encode(>>:

json_encode ( $value, JSON_UNESCAPED_UNICODE );

<代码>JSON_UNESCAPED_UNICODE的选项仅可在PHP版本5.4.0和以后查阅。

感谢。

页: 1 此外,在你编造时,方言保持不变。

you are looking exactly for the funcition json_decode it can convert json strings into utf8

这里是阿拉伯字典。

$re = json_encode( لغة عربية ); 
echo $re ; 
$dd = json_decode($re);
echo $dd ; 
die;

it output : "u0644u063au0629 u0639u0631u0628u064au0629" لغة عربية

more examples here http://php.net/manual/en/function.json-decode.php





相关问题
Simple JAVA: Password Verifier problem

I have a simple problem that says: A password for xyz corporation is supposed to be 6 characters long and made up of a combination of letters and digits. Write a program fragment to read in a string ...

Case insensitive comparison of strings in shell script

The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this?

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

String initialization with pair of iterators

I m trying to initialize string with iterators and something like this works: ifstream fin("tmp.txt"); istream_iterator<char> in_i(fin), eos; //here eos is 1 over the end string s(in_i, ...

break a string in parts

I have a string "pc1|pc2|pc3|" I want to get each word on different line like: pc1 pc2 pc3 I need to do this in C#... any suggestions??

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签