1

I use sample code in this topic :http://stackoverflow.com/questions/5568033/convert-a-strings-character-encoding-from-windows-1252-to-utf-8 to convert windows-1252 string to utf-8 string. It work well on the windows 7 platform. But when i deploy this program on server - Windows Server 2008R2, it doesn't work exactly that i expect.

Example:

On the window 7, the string after converting:

Phần 1: Thị trường chứng khoán và các Công ty phát hành chứng khoán

Phần 2: Quản lý Nhà nước đối với các Công ty phát hành chứng khoán

Phần 3: Thực trạng và phương hướng quản lý phù hợp ở Việt Nam hiện nay

On the windows server 2008R2, the string after converting:

Phần 1: Thị trýờng chứng khoán và các Công ty phát hành chứng khoán

Phần 2: Quản lý Nhà nýớc ðối với các Công ty phát hành chứng khoán

Phần 3: Thực trạng và phýõng hýớng quản lý phù hợp ở Việt Nam hiện nay

I can't find out solution to solve this problem. Would you have any solution for hepling me? Thank you a lots!

Community
  • 1
  • 1
Nghia Minh Le
  • 11
  • 1
  • 4
  • How did you get tiếng Việt in CP1252 encoding? It's lacking plenty of necessary characters. I'd say your assumptions about the source encoding are wrong and maybe you're using the legacy codepage set in Windows (which is different on both machines). Never do that. Always know explicitly what encoding your text is in. You can check in PowerShell by entering `[text.encoding]::default` and see what it outputs. My guess is that it's not the same on both machines (and likely not Windows-1252 on the one where it's working). – Joey May 31 '12 at 09:15
  • 1
    Dear Joey! Thank you so much for your answer! I used your guide, and find out the difference between encoding of client and server. The encoding of client with default English language is Windows-1252, but the server with default Vietnamese language is Windows-1558. I changed the encoding to Windows-1258: **Encoding.GetEncoding(1258). And that's wonderful! It work well. ^__^ – Nghia Minh Le May 31 '12 at 10:35

1 Answers1

2

My guess would be that there is a mismatch between the legacy codepages on your two machines.

You can use

[Text.Encoding]::Default

in PowerShell to figure it out:

IsSingleByte      : True
BodyName          : iso-8859-1
EncodingName      : Western European (Windows)
HeaderName        : Windows-1252
WebName           : Windows-1252
WindowsCodePage   : 1252
IsBrowserDisplay  : True
IsBrowserSave     : True
IsMailNewsDisplay : True
IsMailNewsSave    : True
EncoderFallback   : System.Text.InternalEncoderBestFitFallback
DecoderFallback   : System.Text.InternalDecoderBestFitFallback
IsReadOnly        : True
CodePage          : 1252
Joey
  • 344,408
  • 85
  • 689
  • 683