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

StreamReader and accentuated characters

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

Nov 20 '05 #1
5 6672
Sounds like an encoding problem... can you post some code?

~
Jeremy
"Marcos Ribeiro" <ki**@barretos.com.br> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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


Nov 20 '05 #2
Marcos,
You have the incorrect encoding set on the StreamReader.

When you create the StreamReader use the constructor that accepts a
System.Text.Encoding object, then pass an Encoding object that is the
correct format (code page) for your file.

You can use one of the predefined encodings such as
System.Text.Encoding.UTF8, or you can use Encoding.GetEncoding to get a
specific code page.

Hope this helps
Jay

"Marcos Ribeiro" <ki**@barretos.com.br> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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

Nov 20 '05 #3
Here it is:

Dim sBigString As String
Dim sr As System.IO.StreamReader
sr = System.IO.File.OpenText("MyArq.html")
While sr.Peek <> -1
sBigString &= sr.ReadLine()
End While
sr.Close()

If MyArq.html contain characters like çâé they are zapped from the string
So my Middle Name "Masagão" becomes "Masago"

Marcos

"Jeremy Cowles" <jeremy.cowles[nosp@m]asifl.com> escreveu na mensagem
news:xX****************@twister.tampabay.rr.com...
Sounds like an encoding problem... can you post some code?

~
Jeremy
"Marcos Ribeiro" <ki**@barretos.com.br> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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

Nov 20 '05 #4
Hello,

"Marcos Ribeiro" <ki**@barretos.com.br> schrieb:
I'm trying to read a textfile using System.IO.StreamReader, but all
accentuated characters are skiped.
Why's that? There is any workaround?


You read the file with the wrong encoding. You can specify an encoding in
the StreamReader's constructor.

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 20 '05 #5
Its OK now
Im using
Dim sr As System.IO.StreamReader = New System.IO.StreamReader("Myfile",
System.Text.Encoding.GetEncoding(1252))
While sr.Peek <> -1
sRet &= sr.ReadLine()
End While
sr.Close()
sr = Nothing

Thanks to all

"Marcos Ribeiro" <ki**@barretos.com.br> escreveu na mensagem
news:#U**************@TK2MSFTNGP12.phx.gbl...
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

Nov 20 '05 #6

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...
2
by: yearTiger2002 | last post by:
Our company's back end database server does not handle french accentuated characters well. We need to replace those characters with english letters when validating the form inputs. Any suggestions?...
2
by: Cesar Ronchese | last post by:
Hello, All! I'm working with accentuated characters in my XML files, and I have found problems to load and save it. First, for this case, I always have my XML in memory, and I load it via...
2
by: alien | last post by:
Hi, I'm using a StreamReader (readLine()) to read text from a file, but some lines in the file I'm reading have odd characters, such as the Euro symbol, etc. I find that no matter what encoding I...
7
by: Hans | last post by:
Hi, I need to process files that are created in UTF-7 format. This works fine upto the point where a '+' character (0x2B/43) appears in the line. The string is mutilated... The reader appears...
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....
2
by: jcdperf | last post by:
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...
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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...
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
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...

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.