locked
MBCS to Unicode and viceversa RRS feed

  • Question

  • I have a legacy database storing Chinese characters as MBCS string (MIXED DATA field in DB2 with CCSID set to EBCDIC at the table level). I connect to the database through .NET driver for DB2 in a .NET 3.5 WinForm application and read the data through a reader and msgbox the reader.GetString(0). It shows squareboxes. However if I do a debug.print() of the same, it prints the Chinese characters beautifully in the Visual Studio Output window. I can't install any lang packs or any thing like that. Using system.Text.Encoding, I tried to convert the bytes array from DBCS to Unicode and so on but it did not work. I tried so many things using Encoding that I don't even remember what all I tried today and with whatever strength I have in my brain, I'm left to wonder how Visual studio is able to accomplish this without lang packs. There ought to be a better way in .NET and I simply couldn't find that. Any inputs will be appreciated.
    Tuesday, May 18, 2010 12:11 PM

Answers

  • Duh... Figured it out myself. Issue is not encoding but the font. For some reason, standard font is not displaying the string properly in case of let's say a standard text box. Since the output window of VS is most probably richtext stuff, I tried the same and it worked. Then I tried changing the font of the plain vanilla text box to Arial Unicode and it displays the characters perfectly. Just documenting my observation for others.
    • Marked as answer by eryang Tuesday, May 25, 2010 2:19 AM
    Wednesday, May 19, 2010 5:42 AM

All replies

  • Duh... Figured it out myself. Issue is not encoding but the font. For some reason, standard font is not displaying the string properly in case of let's say a standard text box. Since the output window of VS is most probably richtext stuff, I tried the same and it worked. Then I tried changing the font of the plain vanilla text box to Arial Unicode and it displays the characters perfectly. Just documenting my observation for others.
    • Marked as answer by eryang Tuesday, May 25, 2010 2:19 AM
    Wednesday, May 19, 2010 5:42 AM
  • Hi,

    Thank you so much for sharing your answer to this question!

    If you have any further questions, you are surely welcome to post here again!

    Good luck and have a nice day!


    Sincerely,
    Eric
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, May 25, 2010 2:19 AM