如何在 C# 中从 HttpWebResponse 中读取阿拉伯字符
How to read Arabic characters from HttpWebResponse in C#
我正在尝试在 C# 应用程序中读取我的 firebase 数据库,我正在使用 HttpWebRequest 和响应来获取数据。
firebase 中的数据是阿拉伯语,当我在 C# 应用程序中获取它时,我看到 ??????相反
我的代码:
static void Main()
{
int i = 0;
Console.WriteLine("here1");
while (i < 15)
{
Console.WriteLine("here0");
string URL = "<firebasePath>/.json";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
//request.ContentType = "application/json: charset=utf-8";
//request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1);Accept-Language:ar";
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
using (Stream responsestream = response.GetResponseStream())
{
StreamReader read = new StreamReader(responsestream, Encoding.UTF8);
Console.WriteLine(read.ReadToEnd());
Console.WriteLine("herehere");
}
i++;
}
}
注释掉的列表示我已经尝试过此解决方案但对我不起作用。
输出示例:
{"1964":{"2018-05-08 10:48:33":{"activityOneQuestion":"????? ??????? 3 ????? ????????","activityTwoQuestion":"??...
如何阅读阿拉伯字母?
非常感谢!!
感谢@VahidN在评论中给出了答案,我只是想写在这里方便大家看。
答案:
Console.WriteLine is not able to show Unicode characters. save it to a file and the examine it
成功了。
谢谢!
我正在尝试在 C# 应用程序中读取我的 firebase 数据库,我正在使用 HttpWebRequest 和响应来获取数据。
firebase 中的数据是阿拉伯语,当我在 C# 应用程序中获取它时,我看到 ??????相反
我的代码:
static void Main()
{
int i = 0;
Console.WriteLine("here1");
while (i < 15)
{
Console.WriteLine("here0");
string URL = "<firebasePath>/.json";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
//request.ContentType = "application/json: charset=utf-8";
//request.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1);Accept-Language:ar";
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
using (Stream responsestream = response.GetResponseStream())
{
StreamReader read = new StreamReader(responsestream, Encoding.UTF8);
Console.WriteLine(read.ReadToEnd());
Console.WriteLine("herehere");
}
i++;
}
}
注释掉的列表示我已经尝试过此解决方案但对我不起作用。
输出示例:
{"1964":{"2018-05-08 10:48:33":{"activityOneQuestion":"????? ??????? 3 ????? ????????","activityTwoQuestion":"??...
如何阅读阿拉伯字母?
非常感谢!!
感谢@VahidN在评论中给出了答案,我只是想写在这里方便大家看。
答案:
Console.WriteLine is not able to show Unicode characters. save it to a file and the examine it
成功了。 谢谢!