By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,367 Members | 1,281 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,367 IT Pros & Developers. It's quick & easy.

read extended ascii values

P: 33
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:
Expand|Select|Wrap|Line Numbers
  1. private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             int[] b = new int[100000];
  4.             StreamReader sw = new StreamReader("c: \\28D.09N");
  5.             for (int i = 0; i < 5000; i++)
  6.             {
  7.                 b[i] = sw.Read();
  8.                 //int c = sw.Read();
  9.                 //int a = (int)c;
  10.                 Console.WriteLine(b[i]);
  11.             }
  12.             /*SaveFileDialog sv = new SaveFileDialog();
  13.             sv.Filter = "text file|*.txt";
  14.             if (sv.ShowDialog() == DialogResult.OK)
  15.             {*/
  16.                 StreamWriter sr = new StreamWriter("c: \\bin28D.txt");
  17.                 for (int i = 0; i < 5000; i++)
  18.                 {
  19.                     sr.WriteLine(b[i]);
  20.                 }
  21.                 sw.Close();
  22.             }
any help for the extended ascii values plzzz
Dec 12 '09 #1
Share this Question
Share on Google+
5 Replies

Expert 2.5K+
P: 3,525
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.
Dec 12 '09 #2

P: 33
thanx for the tips
but i was expeting the solution
Dec 12 '09 #3

Expert 2.5K+
P: 3,525
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.
Dec 12 '09 #4

Expert 2.5K+
P: 3,525
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
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.
Dec 12 '09 #5

Expert 2.5K+
P: 3,525
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.
Dec 12 '09 #6

Post your reply

Sign in to post your reply or Sign up for a free account.