473,480 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Encoding problems

WH
Hi,
I use a Streamreader in VB2005 to read text files I made before in NotePad,
but it can't read characters like "é" or "ç". They are omitted, or replaced
by other characters. I tried different encodings, but I can't fix the
problem. In VB6 everything works well. I live in Belgium (Duch language).
Can anyone help me?
Thanks,
WH
Jan 27 '07 #1
4 2322
enconding to mime (base64) or first convert it to hex buffer
"WH" <wi**********@skynet.bewrote in message
news:45**********************@news.skynet.be...
Hi,
I use a Streamreader in VB2005 to read text files I made before in
NotePad, but it can't read characters like "é" or "ç". They are omitted,
or replaced by other characters. I tried different encodings, but I can't
fix the problem. In VB6 everything works well. I live in Belgium (Duch
language).
Can anyone help me?
Thanks,
WH
Jan 27 '07 #2
I would use UTF8 encoding.

This example outputs readable character only in UTF8.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim sw As System.IO.StreamWriter = New
System.IO.StreamWriter("c:\temp\test.txt", False,
System.Text.Encoding.ASCII)
sw.WriteLine("-------------------")
sw.WriteLine("ASCII")
sw.WriteLine("Ligne 2: éàèêô.")
sw.WriteLine("-------------------")
sw.Close()

sw = New System.IO.StreamWriter("c:\temp\test.txt", True,
System.Text.Encoding.UTF8)
sw.WriteLine("-------------------")
sw.WriteLine("UTF8")
sw.WriteLine("Ligne 2: éàèêô.")
sw.WriteLine("-------------------")
sw.Close()

End Sub
--
HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
S2i web inc. (www.s2i.com)
http://www.emoreau.com/

"WH" <wi**********@skynet.bewrote in message
news:45**********************@news.skynet.be...
Hi,
I use a Streamreader in VB2005 to read text files I made before in
NotePad, but it can't read characters like "é" or "ç". They are omitted,
or replaced by other characters. I tried different encodings, but I can't
fix the problem. In VB6 everything works well. I live in Belgium (Duch
language).
Can anyone help me?
Thanks,
WH

Jan 27 '07 #3
WH,

Are you sure that they are gone, I had a while as well that problem, but I
had just set my advance language setting (3th tab in country setting) to
one one which had not these characthers, and therefore it was not showed in
notepad (although I thought it was in some others)..

The streamreader cannot see if it is such a kind of characters or not.

I hope this helps,

Cor
"WH" <wi**********@skynet.beschreef in bericht
news:45**********************@news.skynet.be...
Hi,
I use a Streamreader in VB2005 to read text files I made before in
NotePad, but it can't read characters like "é" or "ç". They are omitted,
or replaced by other characters. I tried different encodings, but I can't
fix the problem. In VB6 everything works well. I live in Belgium (Duch
language).
Can anyone help me?
Thanks,
WH

Jan 27 '07 #4
"WH" <wi**********@skynet.beschrieb:
I use a Streamreader in VB2005 to read text files I made before in
NotePad, but it can't read characters like "é" or "ç". They are omitted,
or replaced by other characters. I tried different encodings, but I can't
fix the problem. In VB6 everything works well. I live in Belgium (Duch
language).
Notepad stores the file with the system's Windows ANSI code page by default.
Thus you have this encoding to read the file. VB6's file access functions
use the Windows ANSI encoding too. That's why reading the file in VB6
works. In .NET you have to pass the appropriate encoding to the
'StreamReader' object's constructor. To obtain the system's Windows ANSI
code page use 'Encoding.Default':

\\\
Imports System.IO
Imports System.Text
....
Dim Reader As New StreamReader(..., Encoding.Default)
....
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jan 27 '07 #5

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

Similar topics

1
5707
by: Irmen de Jong | last post by:
Hi I'm trying to create e-mail content using the email.MIMEText module. It basically works, until I tried to send mail in non-ascii format. What I did, to test both iso-8859-15 and UTF-8...
6
2223
by: Gandalf | last post by:
Hi All! I have a program that looks like this: # -*- coding: iso-8859-2 -*- s1 = 'néz' s2 = raw_input('Please type in "néz":') print repr(s1) print repr(s2)
7
4936
by: Mark | last post by:
Hi... I've been doing a lot of work both creating and consuming web services, and I notice there seems to be a discontinuity between a number of the different cogs in the wheel centering around...
2
2976
by: Vincent Poinot | last post by:
I'd like to implement some sort of search function on my site, so I took Google sample code and tried it, i.e. basically: <form method="GET" action="http://www.google.com/search"> <input...
9
5778
by: Joe Blow | last post by:
Strange problem, Web pages encoded in utf-8 are appearing on customers' browsers as iso-western european. This means that characters like the British £ symbol get messed up. No amount of...
4
3308
by: Curt Fluegel | last post by:
I seem to be having a problem base64 encoding characters above 127. I can encode a sentence like "The big bad dog" without problems, but if I try to encode something like 0xFF I get different...
19
3308
by: Thomas W | last post by:
I'm getting really annoyed with python in regards to unicode/ascii-encoding problems. The string below is the encoding of the norwegian word "fødselsdag". I stored the string as "fødselsdag"...
23
4985
by: Allan Ebdrup | last post by:
I hava an ajax web application where i hvae problems with UTF-8 encoding oc chineese chars. My Ajax webapplication runs in a HTML page that is UTF-8 Encoded. I copy and paste some chineese chars...
8
2663
by: Erwin Moller | last post by:
Hi group, I could use a bit of guidance on the following matter. I am starting a new project now and must make some decisions regarding encoding. Environment: PHP4.3, Postgres7.4.3 I must...
15
6008
by: Bexm | last post by:
Hello I have searched through this forum and it seems some people are having similar problems to me but none of the fixes are fixing mine..! :( I have a table in my database that has two xml...
0
6920
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...
0
7061
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,...
0
7110
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6763
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...
0
7030
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...
1
4799
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...
0
4503
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1313
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 ...
1
574
muto222
php
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.