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(sF ichier)
Dim sLine As String
Do
sLine = sr.ReadLine()
Console.WriteLi ne(sLine
Loop Until sLine Is Nothing
Catch e As Exception
Console.WriteLi ne(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
*-----------------------* 2 2188
Hello,
a similar question appeared in the Spanish dotnet.vb newsgroup.
Use Encoding with 437 code (OEM US):
sr = New StreamReader(sF ichier, System.Text.Enc oding.GetEncodi ng(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(sF ichier) Dim sLine As String Do sLine = sr.ReadLine() Console.WriteLi ne(sLine Loop Until sLine Is Nothing
Catch e As Exception Console.WriteLi ne(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 *-----------------------*
Hello Jorge,
thanks for your help, you put me on the right way. i have used
sr = New StreamReader(sF ichier, Encoding.Defaul t)
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:a7847f66 18]System.Text.Enc oding.GetEncodi ng(437)[/code:1:a7847f66 18]
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.co m
*-----------------------* This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
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)
|
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 -- the character
input is a different matter, at least if I want to remain within
the bounds of the standard library.
|
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 line at a time
and print it out. How can I do this? I wrote the code below but it's
not correct since the fscanf reads one word (terminating in whitespace
or newline) at a time, instead of reading the whole line.
#include <stdio.h>
void...
|
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 default Locale is "en-US" and I open some
french text like this:
StreamReader sr = new StreamReader("C:\\someFrenchFile.txt");
| |
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
|
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
|
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 getting on more or less OK.
So far, I have managed to parse my tab-delimited .txt file properly into
an array, and then use this array to update the tags on a bunch of MP3
audio files. Nice.
|
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
Rattus_norvegicus.fa
(They are FA files that can be opened in any text editor.)
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |