如何处理非打印unicode字符 [英] How can deal with nonprinting unicode characters

查看:98
本文介绍了如何处理非打印unicode字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I want to save ZWJ and ZWNJ in text file have English character, but I get "?" in output file how can I solve this problem? please.





我尝试过:



我想在一个文本文件中保存ZWJ和ZWNJ,但是我没有得到结果。



What I have tried:

Hi, I want to save ZWJ and ZWNJ in a text file, but I do not get the Result.

推荐答案

你可能没有保存你的文本文件作为UTF8或Unicode(来自MSDN):

You are probably not saving your text file as UTF8 or Unicode (from MSDN):
using System;
using System.IO;
using System.Text;

class Test
{
    public static void Main()
    {
        string path = @"c:\temp\MyTest.txt";

        // This text is added only once to the file.
        if (!File.Exists(path))
        {
            // Create a file to write to.
            string createText = "Hello and Welcome" + Environment.NewLine;
            File.WriteAllText(path, createText, Encoding.UTF8);
        }

        // This text is always added, making the file longer over time
        // if it is not deleted.
        string appendText = "This is extra text" + Environment.NewLine;
        File.AppendAllText(path, appendText, Encoding.UTF8);

        // Open the file to read from.
        string readText = File.ReadAllText(path);
        Console.WriteLine(readText);
    }
}


这篇关于如何处理非打印unicode字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆