473,785 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

é writing out from a streamreader??

I'm having a problem with the streamreader class. When i read out of a file,
characters like é are taken out when i do readline. Why does this happen?
When i switch the encoding to ascii, it replaces those characters with a
question mark. How do i get them to read correctly from a file? So the
character é is correctly read into the .net program?
Nov 15 '05 #1
4 2389
This link should tell you all you need to know:
http://www.yoda.arachsys.com/csharp/unicode.html

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"Jason Gleason" <ja***********@ gensurvey.com> wrote in message
news:OT******** ******@TK2MSFTN GP12.phx.gbl...
I'm having a problem with the streamreader class. When i read out of a file, characters like é are taken out when i do readline. Why does this happen?
When i switch the encoding to ascii, it replaces those characters with a
question mark. How do i get them to read correctly from a file? So the
character é is correctly read into the .net program?

Nov 15 '05 #2
This link should tell you all you need to know:
http://www.yoda.arachsys.com/csharp/unicode.html

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"Jason Gleason" <ja***********@ gensurvey.com> wrote in message
news:OT******** ******@TK2MSFTN GP12.phx.gbl...
I'm having a problem with the streamreader class. When i read out of a file, characters like é are taken out when i do readline. Why does this happen?
When i switch the encoding to ascii, it replaces those characters with a
question mark. How do i get them to read correctly from a file? So the
character é is correctly read into the .net program?

Nov 15 '05 #3

"Jason Gleason" <ja***********@ gensurvey.com> wrote in message
news:OT******** ******@TK2MSFTN GP12.phx.gbl...
I'm having a problem with the streamreader class. When i read out of a file, characters like é are taken out when i do readline. Why does this happen?
When i switch the encoding to ascii, it replaces those characters with a
question mark. How do i get them to read correctly from a file? So the
character é is correctly read into the .net program?


When the characters where stored in the stream, a specific text encoding was
used to translate the characters into a sequence of bytes. You need to know
what encoding that was in order to read the stream properly. ASCII won't
work because é isn't in the ASCII character set.

Try other encodings such as UTF8, iso-8859-1, etc. To get an Encoding object
for iso-8859-1, use Encoding.GetEnc oding("iso-8859-1") and pass this to the
StreamReader constructor.
Nov 15 '05 #4

"Jason Gleason" <ja***********@ gensurvey.com> wrote in message
news:OT******** ******@TK2MSFTN GP12.phx.gbl...
I'm having a problem with the streamreader class. When i read out of a file, characters like é are taken out when i do readline. Why does this happen?
When i switch the encoding to ascii, it replaces those characters with a
question mark. How do i get them to read correctly from a file? So the
character é is correctly read into the .net program?


When the characters where stored in the stream, a specific text encoding was
used to translate the characters into a sequence of bytes. You need to know
what encoding that was in order to read the stream properly. ASCII won't
work because é isn't in the ASCII character set.

Try other encodings such as UTF8, iso-8859-1, etc. To get an Encoding object
for iso-8859-1, use Encoding.GetEnc oding("iso-8859-1") and pass this to the
StreamReader constructor.
Nov 15 '05 #5

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

Similar topics

3
24528
by: JSM | last post by:
Hi, I am just trying to port an existing simple encryption routine to C#. this routine simply adds/substracts 10 ascii characters to each character in a text file (except quotes). The routine for decrypting the file works fine however when I encrypt the file, several characters are corrupted. when I looked into it they are always extended ascii characters (eg "x" which is ascii character 120 gets translated to ascii character 130 which...
2
6861
by: melanieab | last post by:
Hi, I'm trying to store all of my data into one file (there're about 140 things to keep track of). I have no problem reading a specific string from the array file, but I wasn't sure how to replace just one item. I know I can get the entire array, then save the whole thing (with a for loop and if statements so that the changed data will be saved), but it seems like a lot of unnecessary reading and writing. Is there a way to directly save...
1
1333
by: Bishoy George | last post by:
I want a link to a nice documentation about writing to a server file by C# using System.IO; .
0
9645
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
9481
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10341
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10095
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
9954
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8979
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...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5383
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...
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.