Convert Json to Unicode and jsonunicode

Source: Internet
Author: User

Convert Json to Unicode and jsonunicode

Enter Text in json format and normal text.

 

/// 20130625 by zhangyl
Private string JsonToUnicode (string input)
{
Input = input. Replace ("\\\"","\"");
Input = input. Replace ("\\/","/");
String result;
If (! Input. Contains ("\ u "))
{
Result = input;
}
Else
{
StringBuilder stringBuilder = new StringBuilder ();
If (input. IndexOf ("\ u")> 0)
{
StringBuilder. Append (input. Substring (0, input. IndexOf ("\ u ")));
Input = input. Substring (input. IndexOf ("\ u "));
}
If (! String. IsNullOrEmpty (input ))
{
String [] array = input. Split (new string []
{
"\ U"
}, StringSplitOptions. RemoveEmptyEntries );
String [] array2 = array;
For (int I = 0; I <array2.Length; I ++)
{
String text = array2 [I];
If (text. Length> 4)
{
String arg = text. Substring (4 );
StringBuilder. Append (char) int. Parse (text. Substring (0, 4), NumberStyles. HexNumber) + arg );
}
Else
{
If (text. Length = 4)
{
StringBuilder. Append (char) int. Parse (text, NumberStyles. HexNumber ));
}
Else
{
If (text. Length <4 & text. Length> 0)
{
StringBuilder. Append (text );
}
}
}
}
}
Result = stringBuilder. ToString ();
}
Return result;
}


How does php convert unicode encoding in json into Chinese characters?

Why can't I display it? The result is as follows: $ d = [{"_ id": {"$ id": "4fda7d42741d727c14000000"}, "name ": "commandid identification", "bc": "123456", "pic": "d: pic \ water.jpg", "aid ": "232fd4df3"}] $ c = [{"_ id": {"$ id": "4fdaa7f3741d725816000000"}, "bc": "012345678", "name ": "Could you refer to the article", "cls": {"id": "125", "name": "Could you refer? "}," Std ": {" name ":" Too many characters "," val ":" 10 "}] cannot be used in IE. What's wrong? Solution ~~

How does one convert unicode to the original Chinese Character in python?

What is unicode after loads is extracted? I suspect you are using python3.

In python2, all IO reads and writes are in byte mode. That is, after encoding. This is also true for java. Only some specific modules in python3 can automatically convert byte to unicode.

In python2, you can use s. decode ('gbk', 'ignore') to convert unicode. However, this should be the case in python3. s. encode ('gbk', 'ignore') becomes byte.

If you like UTF-8, you can use s. encode ('utf-8', 'ignore') and s. decode ('utf-8', 'ignore ')

Try more. The console and files only support encoded strings.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.