|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem w/ special characters in a filestreamusing vb.net 2003, I am reading an ascii text file which is shared with a
legacy DOS program. The characters "«" (ascii code 171) and "¬" (ascii code 172) are used in the file. The DOS app reads these as binary input and when converted to text they translate to characters "½" (ascii code 189) and "¼" (ascii code 188) respectively. When using a StreamReader to read the file the characters do not appear at all. That is the line in the file when viewed with notpad or any other simple text editor may include the line "no more than ¬ inch deep" but when this line is read using the readline method of the streamreader the string returned is "no more than inch deep" How can I find these characters in the filestream and replace them with the "½" and "¼" characters? Erik
Show quote
Hide quote
"Engineerik" <Enginee***@discussions.microsoft.com> schrieb It seems the DOS application reads a DOS encoded file (probably codepage 437 > using vb.net 2003, I am reading an ascii text file which is shared > with a legacy DOS program. The characters "«" (ascii code 171) and > "¬" (ascii code 172) are used in the file. The DOS app reads these > as binary input and when converted to text they translate to > characters "½" (ascii code 189) and "¼" (ascii code 188) > respectively. > When using a StreamReader to read the file the characters do not > appear at all. That is the line in the file when viewed with notpad > or any other simple text editor may include the line "no more than ¬ > inch deep" but when this line is read using the readline method of > the streamreader the string returned is "no more than inch deep" > > How can I find these characters in the filestream and replace them > with the "½" and "¼" characters? "OEM USA") and writes an ANSI encoded file. I think so because the char code of "½" on code page 437 is 171. Try passing System.Text.Encoding.Default to the streamreader when reading the file. Be aware that ASCII (System.Text.Encoding.ASCII) is 7 Bits only (char codes 0-127). Armin "Armin Zingler" wrote: (Lights coming on).... > > Try passing System.Text.Encoding.Default to the streamreader when reading > the file. > ....> > Armin > > I knew there had to be something simple and I have not really had to deal with Encoding stuff much. Thanks for the help. Erik |
|||||||||||||||||||||||