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.