1

I am using sample code in this topic: Convert a string's character encoding from windows-1252 to utf-8 to convert vni-windows string to utf-8 string. However, it didn't work. Here's my code:

Encoding vns1252 = Encoding.GetEncoding(1252);
Encoding unicode = Encoding.UTF8;
byte[] win1252 = vns1252.GetBytes(ems.Nguoi_goi);
byte[] utf8bytes = Encoding.Convert(vns1252, unicode, win1252);
string nguoigoi_utf8 = Encoding.UTF8.GetString(utf8bytes);
Sheet1.Cells[i, 4] = nguoigoi_utf8;

My resuft: "Coâng ty TNHH Dòch Vuï Mua Saém T & T"

Any suggestions on how to convert the VNI-Windows into UTF-8?

Community
  • 1
  • 1
nldt
  • 11
  • 3

2 Answers2

1

The VNI encoding isn't supported by Microsoft (and/or by .NET). There is no corresponding encoder/decoder. At a certain time Microsoft decided to support it, but there were legal problems with this (see https://en.wikipedia.org/wiki/VNI and http://www.siao2.com/2012/09/18/10350350.aspx), so they abandoned the idea and created the Windows-1258 encoding (that is different from VNI).

xanatos
  • 109,618
  • 12
  • 197
  • 280
0

VNI encoding is different from Windows-1252.

Try as the first line instead this:

Encoding vns1252 = Encoding.GetEncoding("VNI");
Daniel Martin
  • 23,083
  • 6
  • 50
  • 70
  • That encoding isn't supported (at least by that `VNI` name) – xanatos Jul 06 '15 at 07:38
  • I think Microsoft doesn't support directly VNI, because it seems to be a proprietary standard... see https://en.wikipedia.org/wiki/VNI and http://www.siao2.com/2012/09/18/10350350.aspx – xanatos Jul 06 '15 at 07:42