Write to a file in ASCII format
-
-
Hi i want to know how can we write some data in ASCII format . means if i write '49' its should not be in character format , instead the equalent character for ASCII 49 ie '1' has to be stored . Please its urgent . thanks in advance Akhil:confused:
-
Hi i want to know how can we write some data in ASCII format . means if i write '49' its should not be in character format , instead the equalent character for ASCII 49 ie '1' has to be stored . Please its urgent . thanks in advance Akhil:confused:
The Char data type in .NET is not ASCII but Unicode. You can easily convert between Char and Int32:
int i = 49; char c = (char)i; char d = (char)49;
You can also write characer codes inside a char or string literal:char e = '\x31'; char f = '\u0031';
--- b { font-weight: normal; } -
Hi i want to know how can we write some data in ASCII format . means if i write '49' its should not be in character format , instead the equalent character for ASCII 49 ie '1' has to be stored . Please its urgent . thanks in advance Akhil:confused:
Hi, There is a built in Encoder to ASCII and from ASCII. Just use System.Text.Encoding.ASCII.GetBytes and pass a string or a character array and it will provide you the ASCII byte array. The using System.Text.Encoding.ASCII.GetChars you can change back from ASCII to character. Hope it helps, Andrei