我将字符串 (UTF-8) 转换为字符数组(在 C# 中)。并在控制台上显示字符数组,但无法在控制台中显示 UTF-8 字符。我该如何解决这个问题?
我使用 IDE Visual Studio 2015 for 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();
}
}
}
输入字符串:hang out [0] => "d"[1] => "i"[2] => " "[3] => "c"[4] => "h"[5] => “o”[6] => “我”
我希望输出为 [0] => "đ"
qq_笑_17
相关分类