UTF-8为Unicode使用C# [英] UTF-8 to Unicode using C#

查看:699
本文介绍了UTF-8为Unicode使用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我。我有编码的响应字符串问题GET请求后:

Help me please. I have problem with encoding response string after GET request:

var m_refWebClient = new WebClient();
var m_refStream = m_refWebClient.OpenRead(this.m_refUri);
var m_refStreamReader = new StreamReader(this.m_refStream, Encoding.UTF8);
var m_refResponse = m_refStreamReader.ReadToEnd();



在调用这个代码我的字符串m_refResponse是之后的 \\\М\\\о\\\й 。它是什么?如何进行编码西里尔?我了很多的尝试后很累。

After calling this code my string m_refResponse is json source with substrings like \u041c\u043e\u0439. What is it? How to encode it for Cyrillic? I am very tired after a lot of attempts.

修正

推荐答案

我失去了一些东西在这里?

Am I missing something here?

这是什么?

\\\М\\\о\\\йМой的字符串文字表示。你不必做任何事情更多,字符串都是Unicode,你有你的西里尔了。

"\u041c\u043e\u0439" is the String literal representation of Мой. You don't have to do anything more, Strings are Unicode, you've got your Cyrillic already.

(除非你的意思是你的的字面的有序列 \\\М\\\о\\\й ,即值\\\\М\\\\о\\\ \й。这不会是编码错误的结果,那会是在服务器上发生的事情,例如,它返回一个JSON字符串,因为JSON和C#中使用相同的 \u 逃脱。如果这是发生了什么使用JSON解析器。)

(Unless you mean you literally have the sequence \u041c\u043e\u0439, ie. the value "\\u041c\\u043e\\u0439". That wouldn't be the result of an encoding error, that would be something happening at the server, for example it returning a JSON string, since JSON and C# use the same \u escapes. If that's what's happening use a JSON parser.)

这篇关于UTF-8为Unicode使用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆