Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

In one of my application I'm using IBM MQ for request/ response everything working fine until I receive response in Thai characters which received/ shown as garbage (lost characters) "I'm writing response to a file using UTF-8 encoding". when I open response and apply Thai character set to the response file in Notepad++ it shows correct value.
Below is the response I received-

<Name1>กลุ่ม</Name1>


For Now I'm writing the response to temporary file on drive and reading that response using encoding as below it works-

Encoding encd = Encoding.GetEncoding(874);
System.IO.File.WriteAllText("D:\\temp_1.txt", _response);
string s = System.IO.File.ReadAllText("D:\\temp_1.txt", encd);


Same I'm trying to achive using string it doesn't work

byte[] data = System.Text.Encoding.Unicode.GetBytes(_response);
string xyz = encd.GetString(data);
oLogger.LogDebugMessage("Response encd: " + xyz);


I dont want to write response to file and read through this doesn't seem feasible. Can anyone suggest anything using string encoding?

What I have tried:

I've tried converting response in string to unicode

<pre>byte[] data = System.Text.Encoding.Unicode.GetBytes(_response);
string xyz = encd.GetString(data);
oLogger.LogDebugMessage("Response encd: " + xyz);
Posted
Comments
[no name] 16-Sep-20 13:11pm    
Sounds like you're confusing garbage with using the wrong font for a particular "presentation" (Notepad++ vs console output).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900