StreamReader(), System.Text.Encoding and German character Ä.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • snedster
    New Member
    • Apr 2010
    • 3

    #1

    StreamReader(), System.Text.Encoding and German character Ä.

    I am consuming data from a web service, and the data is going through a soap extension. Currently it has TextReader reader = new StreamReader(fr om) where from is a Stream. This works great for most values, but when I reach a à characters it shows as a question mark. I updated to StreamReader(fr om, System.Text.Enc oding.Default) and now the à shows correctly, but characters such as Japanese or Chinese or Unicode do not show correctly.
    In php I have solved this issue using mbstring functions such as mb_detect_encod ing and mb_check_encodi ng.

    The data has a UTF-8 header.
    Is there a way that I can reliably detect what type of encoding to declare for the StreamReader so that the correct characters will always show?
    Thanks for any info.
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    If the data is always utf-8, use the utf8 encoding?
    The webservice should declare what encoding type it uses

    Comment

    • snedster
      New Member
      • Apr 2010
      • 3

      #3
      When I set the reader to UTF8 then the à characters turn into �

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        What are you using to view them? The debugger? Notepad?

        Comment

        • snedster
          New Member
          • Apr 2010
          • 3

          #5
          I do not use notepad because if you type "this app can break" and save it and open it, the characters show as squares in a 32 bit system :) So their character encoding detection seems to be faulty :)

          The data from the web service is being inserted into Excel, so that is where I am viewing the data. But the data is also printed in the console in debug mode and written to a file as well.

          I did see this post here, but it did not help with unicode characters.

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            Hmm have you tried adjusting the font?

            Comment

            Working...