For my test data I'm using the characters:
漢字仮名交じり文
My code that writes a file is:
// Create license key file
if (!File.Ex开发者_开发知识库ists(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.
There are two sources to this problem:
- Your file is not encoded correctly. If you are using anything other than ASCII characters, then you need to make the conscious decision to choose the correct encoding. The fact that copying and pasting works makes me think that your encoding is OK, but you still seem unaware of the fact that this is occurring behind the scenes.
- Your editor is trying display unicode characters using a font that cannot render them correctly. Not every font supports Unicode. Change the font to a font that can render Unicode characters and you should be good to go.
EDIT: As a side note, understanding the joke here will also do you some good.
精彩评论