473,383 Members | 1,725 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,383 software developers and data experts.

Reading text files and accentuated characters

Hello,

I have small problems while reading of text files containing
accentuated characters. (like é è à ç ...). I use this basic code :
Dim sr As StreamReader
Try
sr = New StreamReader(sFichier)
Dim sLine As String
Do
sLine = sr.ReadLine()
Console.WriteLine(sLine
Loop Until sLine Is Nothing

Catch e As Exception
Console.WriteLine(e.Message)
Finally
sr.Close()
End Try
When sLine is printed in the console (or when i have to manipulate
this string), all the accentuated characters have disappeared from
sLine. For example,
"Début de programme" is replaced by "Dbut de programme".

I have tried also FileStream with UTF8Encoding to read the text file,
but with no more success.

Any help is welcome.

Thanks,

Cedric

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 21 '05 #1
2 2158
Hello,

a similar question appeared in the Spanish dotnet.vb newsgroup.

Use Encoding with 437 code (OEM US):

sr = New StreamReader(sFichier, System.Text.Encoding.GetEncoding(437), False)

Try it and give me your feedback please. ;-)
Kind Regards,

Jorge Serrano
MVP VB.NET
"jcdperf" wrote:
Hello,

I have small problems while reading of text files containing
accentuated characters. (like é è Ã* ç ...). I use this basic code :
Dim sr As StreamReader
Try
sr = New StreamReader(sFichier)
Dim sLine As String
Do
sLine = sr.ReadLine()
Console.WriteLine(sLine
Loop Until sLine Is Nothing

Catch e As Exception
Console.WriteLine(e.Message)
Finally
sr.Close()
End Try
When sLine is printed in the console (or when i have to manipulate
this string), all the accentuated characters have disappeared from
sLine. For example,
"Début de programme" is replaced by "Dbut de programme".

I have tried also FileStream with UTF8Encoding to read the text file,
but with no more success.

Any help is welcome.

Thanks,

Cedric

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*

Nov 21 '05 #2
Hello Jorge,

thanks for your help, you put me on the right way. i have used
sr = New StreamReader(sFichier, Encoding.Default)
It seems to use the default encoding of the system in order to read
the text file. It works well for me. You have to use this for the
StreamWriter too if you want to write accentuated characters.

[code:1:a7847f6618]System.Text.Encoding.GetEncoding(437)[/code:1:a7847f6618]
doesn't work on my system, certainly because it's not a spanish sytem
but a french one :D

Regards,

Cedric

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 21 '05 #3

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

Similar topics

6
by: Jean-Marc Molina | last post by:
Hello, I'm trying to generate a RSS newsfeed using the DOM XML functions. However I can't find a way to use accentuated characters. I even tried to specify a character encoding set but it...
3
by: Ndeye | last post by:
hi everybody, I would like to parse an xml file containing some accentuated characters like è. This causes my java program to throw this error : file:/c:/dxl/Abbink.xml; Line 216; Column 26...
50
by: Michael Mair | last post by:
Cheerio, I would appreciate opinions on the following: Given the task to read a _complete_ text file into a string: What is the "best" way to do it? Handling the buffer is not the problem...
40
by: googler | last post by:
I'm trying to read from an input text file and print it out. I can do this by reading each character, but I want to implement it in a more efficient way. So I thought my program should read one...
14
by: Alex Leduc | last post by:
I'm trying to load ASCII files that contain characters from the French language in a way that is independant of whatever Locale the machine is configured to use. So If I have machine who's...
13
by: Pascal Cloup | last post by:
Hello, The methods Read() of the class StreamReader don't read the accentuated characters. When an accentuated character is present in a file, Read() skip it and read the following character....
5
by: Marcos Ribeiro | last post by:
Hi I'm trying to read a textfile using System.IO.StreamReader, but all accentuated characters are skiped. Why's that? There is any workaround? Thanks Marcos
2
by: Clive Green | last post by:
Hello peeps, I am using PHP 5.2.2 together with MP3_Id (a PEAR module for reading and writing MP3 tags). I have been using PHP on the command line (Mac OS X Unix shell, to be precise), and am...
10
by: lancer6238 | last post by:
Hi all, I'm having programs reading from files. I have a text file "files.txt" that contains the names of the files to be opened, i.e. the contents of files.txt are Homo_sapiens.fa...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.