Tom*_*len 4 c# asp.net encoding text utf-8
对于我的测试数据,我使用的是字符:
????????
Run Code Online (Sandbox Code Playgroud)
我编写文件的代码是:
// Create license key file
if (!File.Exists(Settings.LicenseFilesLocation + "/" + EmailAddress + "/" + LicenseFileName))
{
HttpContext.Current.Response.Write(Name.Normalize());
HttpContext.Current.Response.End();
// UTF-8
StreamWriter License = File.CreateText(Settings.LicenseFilesLocation + "/" + EmailAddress + "/" + LicenseFileName);
License.WriteLine("Licensed to: " + Name.Normalize());
License.Flush();
License.Close();
Run Code Online (Sandbox Code Playgroud)
正如您所看到的那样,我在将值保存到文件之前打印该值以进行检查,并且打印正确.但是在保存的文本文件中,当我在记事本中打开它时,它会以很多正方形出现(见截图):

当我复制并粘贴这些字符时,它们会正确复制和粘贴:
????????
Run Code Online (Sandbox Code Playgroud)
我们有很多客户说他们的许可证文件的名称是他们不喜欢的正方形.我们打开并验证此文件的软件程序也将其名称显示为正方形.
任何想法如何解决这一问题?我们想要它,以便当客户打开他们的许可证txt文件时,它显示他们的名字,没有正方形.