写入文件会出现方块
对于我的测试数据,我使用以下字符:
漢字仮名交じり文
我写入文件的代码是:
// 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();
如您所见,我在将值保存到文件之前打印该值以进行检查,并且打印正确。但是,在保存的文本文件中,当我在记事本中打开它时,它会显示为很多方块(请参见屏幕截图):
当我复制并粘贴这些字符时,它们会正确复制并粘贴为:
漢字仮名交じり文
我们有很多客户说他们的许可证文件中的名字位于他们不喜欢的正方形中。我们打开并验证该文件的软件程序也将其名称显示为正方形。
有什么想法如何解决这个问题吗?我们希望这样当客户打开他们的许可证 txt 文件时,它会显示他们的完整姓名,而不带方块。
For my test data I'm using the characters:
漢字仮名交じり文
My code that writes a file is:
// 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();
As you can see I'm printing the value before I save it to file to check it, and it is printing correctly. However in the saved text file when I open it in notepad, it's coming out as lots of squares (see screenshot):
When I copy and paste these characters they copy and paste correctly as:
漢字仮名交じり文
We are having a lot of customers saying their license file has their name in squares which they don't like. Our software program that opens and verifies this file is also showing their name as squares.
Any ideas how to fix this? We want it so that when customers open their license txt file it shows their name in full without squares.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此问题有两个来源:
编辑:作为旁注,理解这个笑话这里也会对你有一些好处。
There are two sources to this problem:
EDIT: As a side note, understanding the joke here will also do you some good.