read extended ascii values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • siddhanta
    New Member
    • Oct 2009
    • 33

    read extended ascii values

    hi,
    i read the ascii value from a file and wrote the decimal one in other file.
    But values above "127" i.e. extended ascii are printed as" 65533."
    here ais wat i did:
    Code:
    private void button1_Click(object sender, EventArgs e)
            {
                int[] b = new int[100000];
                StreamReader sw = new StreamReader("c: \\28D.09N");
                for (int i = 0; i < 5000; i++)
                {
                    b[i] = sw.Read();
                    //int c = sw.Read();
                    //int a = (int)c;
                    Console.WriteLine(b[i]);
                }
                /*SaveFileDialog sv = new SaveFileDialog();
                sv.Filter = "text file|*.txt";
                if (sv.ShowDialog() == DialogResult.OK)
                {*/
                    StreamWriter sr = new StreamWriter("c: \\bin28D.txt");
                    for (int i = 0; i < 5000; i++)
                    {
                        sr.WriteLine(b[i]);
                    }
                    sw.Close();
                }
    any help for the extended ascii values plzzz
    Last edited by tlhintoq; Dec 12 '09, 09:41 AM. Reason: [CODE] ...Your code goes between code tags [/CODE]
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

    Sid: Let me be clear here. You have started over a dozen threads. You have been told this many times. If you can't be bothered to format your questions to make it easier on the volunteers trying to help you, then I wouldn't be surprised if the volunteers here just stopped reading your questions.

    Comment

    • siddhanta
      New Member
      • Oct 2009
      • 33

      #3
      thanx for the tips
      but i was expeting the solution

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        thanx for the tips
        but i was expeting the solution
        Yeah, that is what I am coming to realize from all of your posts... You are expecting the solutions from someone else.

        Comment

        • tlhintoq
          Recognized Expert Specialist
          • Mar 2008
          • 3532

          #5
          Read the microsoft documentation

          Have you considered that you might have to read up on the functions you are using so you *understand* what they are doing?

          For example: Reading the MSDN page for streamreader reveals
          Originally posted by MSDN
          StreamReader defaults to UTF-8 encoding unless specified otherwise, instead of defaulting to the ANSI code page for the current system. UTF-8 handles Unicode characters correctly and provides consistent results on localized versions of the operating system.

          Comment

          • tlhintoq
            Recognized Expert Specialist
            • Mar 2008
            • 3532

            #6
            Do you know for FACT what the contents of the file are and how they were written? Or are you assuming it is ASCII?

            HINT: Streamwriter also defaults to UTF-8, so if you wrote the file thinking it was ASCII then it is possible that streamwriter converted it to unicode.

            Comment

            Working...