0

I have a funny problem after i migrated to .NET Framework 4.5.2, here are my code:

QuoteMachineryColor c1 = new QuoteMachineryColor();
      c1.ColorName = "单色";  // Problem in here
      c1.InclusiveOperationQuantity = 2000;
                c1.InitialCost = 300;
                c1.PrintPlateFeePerSet = 40;
                c1.QuoteMachinery = qm;
                qmcHandler.Save(c1, false);

qmcHandler is using nhibernate to persist the object to database, and the ColorName end up with in database is ¶Ô¿ª»ú, however exactly the same code was working fine in the same machine with .NET Framework 4.0.

Anyone got a clue?

OS: Windows 8.1 Enterprise English
Visual Studio 2015
.NET Framework 4.5.2
Eddy Ma
  • 98
  • 9
  • "¿ª»" is forever something you want to watch out for. It is the utf-8 encoding of U+FEFF, the "zero-width no-break space" codepoint. Very commonly used for the BOM, the Byte Order Mark. Whatever you are doing, and it certainly isn't the code you posted in your snippet, you are doing it wrong. Most typically reading a text file wrong. – Hans Passant Sep 30 '15 at 09:47
  • actually that is what i get µ¥É«, but that doesn't explain why it doesn't happen in the my old framework version – Eddy Ma Sep 30 '15 at 11:13

2 Answers2

0

I just figured out how to the problem, i put in another Chinese character and save and visual studio seems to handle the encoding properly.

The problem was when i upgraded to .net framework 4.5.2 i also upgrade my visual studio and it seems to save the file in different encoding rather than utf8.

Eddy Ma
  • 98
  • 9
0

after changed all the files with the encoding of UTF8 fixed the problem

Eddy Ma
  • 98
  • 9