我将字符串(UTF-8)转换为char数组(在C#中)。并在char数组上显示到控制台,但在Console中无法显示UTF-8字符。我该如何解决这个问题?
我将IDE Visual Studio 2015用于C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace array
{
class Program
{
#region Convert String to char array
static void stringtochar()
{
string str0;
Console.OutputEncoding = Encoding.UTF8;
Console.Write("Nhập Chuỗi Ký Tự :");
str0 = Console.ReadLine();
Char[] str_arr = new Char[100]; // Create array
Array.Copy(str0.ToCharArray(), str_arr,str0.Length);
for (int i = 0; i < str0.Length; i++) {
Console.Write("[{0}] => \"{1}\"", i, str_arr[i]); }
Console.ReadLine();
}
#endregion
static void Main(string[] args)
{
stringtochar();
}
}
}
NhậpChuỗiKýTự:đichơi [0] =>“ d” [1] =>“ i” [2] =>“” [3] =>“ c” [4] =>“ h” [5] =>“ o” [6] =>“ i”
我希望输出为[0] =>“đ”
答案 0 :(得分:0)
您的字符串采用unicode。因此,将编码更改为unicode,并同时添加输入编码
redis>=2.10.0,<3.0.0