Asked by:
Unable to display Chinese characters

Question
-
User-2040848225 posted
Hi,
I have a file which is in ebcidic format.
I have the change the encoding of this file to UTF-8, so that it could display data which both in English and Chinese.
I used StreamReader/StreamReader to do this,but i m able to display only English Characters and not the Chinese.
How can I achieve this?Please help
Friday, April 23, 2021 7:05 AM
All replies
-
User1535942433 posted
Hi user3124,
As far as I think,if it is simplified chinese usually it is gb2312 and for the traditionnal chinese it is usually the Big5.
More details,you could refer to below article:
https://stackoverflow.com/questions/336781/how-to-read-a-chinese-text-file-from-c
Best regards,
Yijing Sun
Friday, April 23, 2021 8:17 AM -
User753101303 posted
Hi,
And Chinese chracters are shown as a ? character or as wrong random characters? You then use this file directly or you render its content on your ASP.NET site?
AFAIK C# uses the System.Text.Encoding.Unicode and characters are converted to UTF-8 depending on the web site configuration. If you convert from edcdic to utf8 and then renders that on your site I suspect you could have an extra conversion.
If this is the case I wouidl try to convert from ebcdic to Unicode and Unicode to utf-8 will be done by ASP.NET
BTW: what happens for Chinese characters? You are seeing a single ? character instead or random wrong characters ?
Friday, April 23, 2021 8:24 AM -
User-2040848225 posted
Hi,
The Chinese characters are displayed something like this
éVïã$5Àô^ü<î!Õ(±!*è&éæéàîÐä (0^U!Í(Y&î+¶â,Friday, April 23, 2021 8:49 AM -
User1535942433 posted
Hi user3124,
It's not random wrong characters.Do you have other operations like encoding,decoding?
Best regards,
Yijing Sun
Wednesday, April 28, 2021 5:33 AM -
User753101303 posted
Seems to me a wrong encoding is applied at some point maybe one more than needed. I would really try to convert from EBCDIC to System.Text.Encoding.Unicode rather than to Utf8. When rendering content to the browser, the Unicode to utf8 e,ncoding (depending on how the site is configured) should be done for you.
If you can make available a small sample file, give the exact EBCDIC encoding beign use and the final Chinese characters you expect, maybe someone could give this a try ?
Edit: for now I suspect you end up with an Utf8 string wich is considered as Unicode and encoded to Utf8 for you by ASP.NET causing wrong characters to be shown...
Wednesday, April 28, 2021 7:28 AM