在开发过程中遇到一个问题,要求把一个富文本的字符串生成一个html文件,结果中文出现乱码,试了好多次终于发现用NCR编码可以解决。查了好多资料终于解决,记录一下
界面如图
代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//textBox2.Text= gb2312_utf8(textBox1.Text);
string hz = textBox1.Text.ToString();
textBox2.Text = CheckStringChineseUn(hz);
}
public static string Unicode16(string hz)
{
byte[] uc = Encoding.Unic