今天在调用一个接口的时候,中文一直乱码,当时就各种搜,,,
{"TaskId":12732823,"HospitalId":4,"TaskNo":"42312120179","PatientName":"æ丽ç´","PatientLocation":"æ°é¢ææ¯å®¤||æ丽ç´"}
只要是中文的 我收到都是乱码,刚开始都是js版本的都能解开,倒是C#用了各种解码还是乱码,后来偶尔看到一篇文章
var utf8String = "[{\"PatientName\":\"æ¨æå¤\",\"PatientLocation\":\"æ°é¢å¤è室|26åº|æ¨æå¤\",\"SourceDeptId\":11907,\"Sourcedept\";232}]"; // copy the string as UTF-8 bytes. byte[] utf8Bytes = new byte[utf8String.Length]; for (int i = 0; i < utf8String.Length; ++i) { utf8Bytes[i] = (byte)utf8String[i]; } var s = Encoding.UTF8.GetString(utf8Bytes, 0, utf8Bytes.Length);
竟然可以了!!!
标签:C#,UTF8,utf8String,utf8Bytes,乱码,--,Length From: https://www.cnblogs.com/FanAspx/p/17897873.html