Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Missing special symbols

Missing special symbols

Scheduled Pinned Locked Moved C#
helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sebastian T Xavier
    wrote on last edited by
    #1

    Hello, I was trying to get the content of a file in a string. I have used the following code ...

            String strContent = "";
            FileStream flDoc = new FileStream(m\_tbxBrowser.Text, FileMode.Open, FileAccess.Read);
            Byte\[\] bytContent = new Byte\[flDoc.Length\];
            flDoc.Read(bytContent, 0, Convert.ToInt32(flDoc.Length));
            strContent = System.Text.ASCIIEncoding.ASCII.GetString(bytContent);
    

    But in the output, strContect some special symbols like

    ®

    is missing, and is replaced by

    ???

    Can anyone help me to solve this? Thanks in advance.

    Sebastian

    A 1 Reply Last reply
    0
    • S Sebastian T Xavier

      Hello, I was trying to get the content of a file in a string. I have used the following code ...

              String strContent = "";
              FileStream flDoc = new FileStream(m\_tbxBrowser.Text, FileMode.Open, FileAccess.Read);
              Byte\[\] bytContent = new Byte\[flDoc.Length\];
              flDoc.Read(bytContent, 0, Convert.ToInt32(flDoc.Length));
              strContent = System.Text.ASCIIEncoding.ASCII.GetString(bytContent);
      

      But in the output, strContect some special symbols like

      ®

      is missing, and is replaced by

      ???

      Can anyone help me to solve this? Thanks in advance.

      Sebastian

      A Offline
      A Offline
      Alan N
      wrote on last edited by
      #2

      The ASCII encoder substitutes a ? when it encounters a character code above 127. What you probably have in the file is an extended ascii character set, the most common of which is represented in Windows by the code page 1252, Single Byte Character Sets (SBCS)[^]. You can get an instance of the encoding with Encoding coder = Encoding.GetEncoding(1252); If you are going to write to the file I strongly suggest that you do some round trip tests to check that you have selected the correct encoding. i.e. Read the file Convert to a string using the encoding Convert the string back to bytes Write to a new file Check that the orignal and rewritten file are identical Alan.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups