473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem w/ special characters in a filestream

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?

Erik
Mar 17 '06 #1
2 2537
"Engineerik" <En********@discussions.microsoft.com> schrieb
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?

It seems the DOS application reads a DOS encoded file (probably codepage 437
"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

Mar 17 '06 #2


"Armin Zingler" wrote:
....

Try passing System.Text.Encoding.Default to the streamreader when reading
the file.
....> Armin

(Lights coming on)
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

Mar 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jack Wright | last post by:
Dear All, In a multiline field if I enter the following way: Mangesh Anant Kodilkar There is a carriage return after each word. Now when I press save,it loses the CRLF characters. This is not...
4
by: Max | last post by:
I'm using StreamReader.ReadToEnd() to populate and string from a file and then display it as a literal on my web site. The problem is I'm losing all the special characters like Æ,Ø, and Å that...
1
by: Snuyt | last post by:
Hello, I try to export some text to a textfile. But when I use special characters such as é, à, è, ... I get some weird characters in the resulting file: "saisonnières et thématiques."...
5
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file"....
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
10
by: jcsnippets.atspace.com | last post by:
Hi everybody, I'm trying to read a file containing a list of addresses. Most of these addresses are based in Germany, so there are a lot of names which have special characters like München and...
31
by: Sam of California | last post by:
Is it accurate to say that "the preprocessor is just a pass in the parsing of the source file"? I responded to that comment by saying that the preprocessor is not just a pass. It processes...
3
KevinADC
by: KevinADC | last post by:
Purpose The purpose of this article is to discuss the difference between characters inside a character class and outside a character class and some special characters inside a character class....
3
by: =?Utf-8?B?TG9yZW4=?= | last post by:
I’m trying to encrypt and decrypt a file in vb.net. I am using the TripleDESCryptoServiceProvider encryption found in System.Security.Cryptography. Below is the code for my Encrypt and Decrypt...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.