473,664 Members | 2,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

StreamReader and accentuated characters

Hi
I'm trying to read a textfile using System.IO.Strea mReader, but all
accentuated characters are skiped.
Why's that? There is any workaround?
Thanks
Marcos

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

~
Jeremy
"Marcos Ribeiro" <ki**@barretos. com.br> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi
I'm trying to read a textfile using System.IO.Strea mReader, 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.Enc oding 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.Enc oding.UTF8, or you can use Encoding.GetEnc oding to get a
specific code page.

Hope this helps
Jay

"Marcos Ribeiro" <ki**@barretos. com.br> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi
I'm trying to read a textfile using System.IO.Strea mReader, 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.Strea mReader
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.cowle s[nosp@m]asifl.com> escreveu na mensagem
news:xX******** ********@twiste r.tampabay.rr.c om...
Sounds like an encoding problem... can you post some code?

~
Jeremy
"Marcos Ribeiro" <ki**@barretos. com.br> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi
I'm trying to read a textfile using System.IO.Strea mReader, 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.Strea mReader, 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.Strea mReader = New System.IO.Strea mReader("Myfile ",
System.Text.Enc oding.GetEncodi ng(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******** ******@TK2MSFTN GP12.phx.gbl...
Hi
I'm trying to read a textfile using System.IO.Strea mReader, 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
2949
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 doesn't solve the problem. Error I get : XML Parsing Error: not well-formed Location: news.php?action=syndicate&format=rss2 Line Number 1, Column 102:<?xml version="1.0" encoding="ISO-8859-15"?><rss
3
7958
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 XSL Error: Could not parse c:\dxl\Abbink.xml document! XSL Error: SAX Exception Invalid UTF-8 code. (bytes: 0xffffffe9 0x20)
2
12456
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? I've never delt with foreign languages before...any help greatly apprieciated!
2
2240
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 LoadXML (please, ignore incorrect concatenations for this sample): Dim cXml As New Xml.XmlDocument
2
3116
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 use with the StreamReader, these characters either get entirely ignored, replaced with a "?", or replaced by some other character. Is there anything I can do to make this work, or should I use something like BinaryReader? Thanks.
7
4799
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 to have a bug - or am I doing something wrong here??? The code: StreamReader Reader = new StreamReader
13
2205
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. Missing something? Thanks for help P. Cloup
2
2176
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 StreamReader(sFichier) Dim sLine As String
0
8437
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
8348
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
8861
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...
0
8636
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
7375
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
6187
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
4351
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2764
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
2
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.