首页 > 解决方案 > Gridview 显示不同的字符而不是 utf-8 中的字符

问题描述

我将 JSON 数据解析为具有 utf-8 字符的 gridview,但 gridview 中的数据不显示 utf-8。我在 gridview 中对列的标题进行了硬编码,它显示了 utf-8 字符。我补充说:

 <system.web>
 <globalization fileEncoding="utf-8" requestEncoding="utf-8" 
 responseEncoding="utf-8" culture="en-US"/>` and `<meta http-equiv="content- 
 type" content="text/html; charset=utf-8" />

但它没有正确显示字符。

这是我的解析器:

public static List<Currency> ParseCurrency()
{
    using (WebClient webClient = new System.Net.WebClient())
    {
        WebClient client = new WebClient();
        var json = client.DownloadString("http://api.hnb.hr/tecajn/v2");
        List<Currency> currencies =
        JsonConvert.DeserializeObject<List<Currency>>(json);
        Console.WriteLine(currencies.Count);
        return currencies;
    }
}

标签: c#asp.netjsongridviewutf-8

解决方案


推荐阅读