C
C#4mo ago
localhost

Why Are Strings in My ASP.NET 4.8 Web Application Converting to Random Chinese Characters?

I have posted this question in detail on stackoverflow here at https://stackoverflow.com/questions/79209878/why-are-strings-in-my-asp-net-4-8-web-application-converting-to-random-chinese-c can anyone help please!
Stack Overflow
Why Are Strings in My ASP.NET 4.8 Web Application Converting to Ran...
We have an ASP.NET Web project built on .NET Framework 4.8 that has been running smoothly for 7–8 years. However, starting last month, we encountered an issue where strings are being converted into
5 Replies
ero
ero4mo ago
Looks like an encoding discrepancy to me
localhost
localhostOP4mo ago
Could you clarify what exactly seems off in the encoding?
MODiX
MODiX4mo ago
ero
REPL Result: Success
string input = "select isnull(ReportTitle,'Journal Voucher') from gen_VoucherTypes where VoucherType = 6 and LogSourceID = 0";
byte[] inBytes = Encoding.UTF8.GetBytes(input);

string output = Encoding.Unicode.GetString(inBytes);
Console.WriteLine(output);
string input = "select isnull(ReportTitle,'Journal Voucher') from gen_VoucherTypes where VoucherType = 6 and LogSourceID = 0";
byte[] inBytes = Encoding.UTF8.GetBytes(input);

string output = Encoding.Unicode.GetString(inBytes);
Console.WriteLine(output);
Console Output
敳敬瑣椠湳汵⡬敒潰瑲楔汴ⱥ䨧畯湲污嘠畯档牥⤧映潲敧彮潖捵敨呲灹獥眠敨敲嘠畯档牥祔数㴠㘠愠摮䰠杯潓牵散䑉㴠〠
敳敬瑣椠湳汵⡬敒潰瑲楔汴ⱥ䨧畯湲污嘠畯档牥⤧映潲敧彮潖捵敨呲灹獥眠敨敲嘠畯档牥祔数㴠㘠愠摮䰠杯潓牵散䑉㴠〠
Compile: 424.521ms | Execution: 22.009ms | React with ❌ to remove this embed.
localhost
localhostOP4mo ago
@ero How can it be converted to UTF-8 automatically after years?
ero
ero4mo ago
That I don't know It's just a suspicion as well, I might be incorrect

Did you find this page helpful?