473,788 Members | 2,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2554
"Engineerik " <En********@dis cussions.micros oft.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.Enc oding.Default to the streamreader when reading
the file.

Be aware that ASCII (System.Text.En coding.ASCII) is 7 Bits only (char codes
0-127).

Armin

Mar 17 '06 #2


"Armin Zingler" wrote:
....

Try passing System.Text.Enc oding.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
2234
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 correct. Even after the page is reloaded the CRLF's are lost. I get this problem on my PC (XP), on Win (2000), on Win (NT & 98). So I
4
6079
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 originates in the file I'm reading. Do I have to tell streamreader what characterset I'm using or something? -Max
1
1022
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." instead of "saisonnières et thématiques." Here is the code:
5
8631
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". Same file path containing special characters works fine in one machine, but doesn't work in other. I am using following API function to get short file path. Declare Auto Function GetShortPathName Lib "kernel32" (ByVal lpszLongPath As
16
4929
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 Microsoft must be installed on their servers. Now german Umlaute (ä, ü, ö) and quotes are returned incorrectly in SOAP fault responses. This can be easily verified: Implement the following in a web service method (just raises a SOAPException with a...
10
5882
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 the ever-present "Straße". The code is as follows: FileStream fs = new FileStream(fi.FullName, FileMode.Open); StreamReader sr = new StreamReader(fs, Encoding.Default);
31
2936
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 statements that the compiler does not process. The good people in the alt.comp.lang.learn.c-c++ newsgroup insist that the preprocessor is just one of many passes. The preprocessor processes a grammer unique to the preprocessor and only that grammer. ...
3
10202
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. This is not a regular expression tutorial. Assumes you are already familiar with basic regular expression concepts and terminology. If not, you may want to read some regular expression tutorial. See the end of the article for links to online resources....
3
3079
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 functions. While my functions read and write files the encryption/decryption is not working properly. My test file has an original length of 66,048 bytes. My encrypted file ends up with 66,056 bytes … 8 bytes more than my original. When I...
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10175
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10112
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3675
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.