473,397 Members | 2,099 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,397 software developers and data experts.

Accent problem

Hi,

Can anyone please help me?

I've wrote a small application that reads the content from a text-file.
Some characters are not displayed correcly.

I noticed the text-file uses different types of Accent Signs (').

Is there some simple methode to replace all of them to just one kind ?

thanx

Kind regards

John
Aug 14 '07 #1
7 1855
"John Devlon" <jo********@hotmail.comschrieb
Hi,

Can anyone please help me?

I've wrote a small application that reads the content from a
text-file. Some characters are not displayed correcly.

I noticed the text-file uses different types of Accent Signs (').

Is there some simple methode to replace all of them to just one kind
?

thanx

You must use the correct encoding when reading from the file. When creating
a StreamReader pass the correct System.Text.Encoding instance to it's
constructor.
Armin

Aug 14 '07 #2

Hi,

I added the code below i'm using. I'm using an array instead of an
arraylist. It's not something i'm proud off, but it works...
Where do I have to add the encoding ?

John

Private arrContentFile() As String
Dim oFile As System.IO.File
Dim oRead As System.IO.StreamReader

Private Sub ReadfileTest(ByVal strFilename As String)
Dim intCount As Int64 = 0
Dim strLine As String

Dim objStreamReader = New System.IO.StreamReader(strFilename)

strLine = objStreamReader.ReadLine

Do While Not strLine Is Nothing
If Not (IsNothing(arrContentFile)) Then
intCount = arrContentFile.GetUpperBound(0) + 1
End If
ReDim Preserve arrContentFile(intCount)
arrContentFile(intCount) = strLine

strLine = objStreamReader.ReadLine
Loop

objStreamReader.Close()

End Sub


"Armin Zingler" <az*******@freenet.dewrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
"John Devlon" <jo********@hotmail.comschrieb
>Hi,

Can anyone please help me?

I've wrote a small application that reads the content from a
text-file. Some characters are not displayed correcly.

I noticed the text-file uses different types of Accent Signs (').

Is there some simple methode to replace all of them to just one kind
?

thanx


You must use the correct encoding when reading from the file. When
creating a StreamReader pass the correct System.Text.Encoding instance to
it's constructor.
Armin

Aug 14 '07 #3
"John Devlon" <jo********@hotmail.comschrieb
>
Hi,

I added the code below i'm using. I'm using an array instead of an
arraylist. It's not something i'm proud off, but it works...
Where do I have to add the encoding ?

John

Private arrContentFile() As String
Dim oFile As System.IO.File
Dim oRead As System.IO.StreamReader

Private Sub ReadfileTest(ByVal strFilename As String)
Dim intCount As Int64 = 0
Dim strLine As String

Dim objStreamReader = New System.IO.StreamReader(strFilename)

strLine = objStreamReader.ReadLine

Do While Not strLine Is Nothing
If Not (IsNothing(arrContentFile)) Then
intCount = arrContentFile.GetUpperBound(0) +
1 End If
ReDim Preserve arrContentFile(intCount)
arrContentFile(intCount) = strLine

strLine = objStreamReader.ReadLine
Loop

objStreamReader.Close()

End Sub


"Armin Zingler" <az*******@freenet.dewrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
"John Devlon" <jo********@hotmail.comschrieb
Hi,
>
Can anyone please help me?
>
I've wrote a small application that reads the content from a
text-file. Some characters are not displayed correcly.
>
I noticed the text-file uses different types of Accent Signs
(').
>
Is there some simple methode to replace all of them to just one
kind ?
>
thanx

You must use the correct encoding when reading from the file. When
creating a StreamReader pass the correct System.Text.Encoding
instance to it's constructor.
Armin
First, you should enable Option Strict.

Then, as written, the Encoding must be passed to the constructor of the
StreamReader:

Dim objStreamReader As New System.IO.StreamReader( _
strFilename, System.Text.Encoding.Default _
)

I don't know which encoding has been used to write the file, so you first
have to know this and replace "Default" by the encoding to be used.
Side notes:
- You can write "Do Until" instead of "Do While Not"
- The "Is" Operator is more straightforward than calling the IsNothing
function.
- Yes, you could have used an Arraylist. ;-) Or, in FW 2.0, a List(Of
String).

Armin

Aug 14 '07 #4
Dear Mr. Zingler,

Thanx for your tips... it was very usefull....

But problem is getting more complex...

The files I'm trying to read are text-file, created in notepad, using the
ANSI encoding...
Resaving a file in notepad to UTF and adjusting the application (encoding
UTF) works great and solves the problem...

However, I can't resave every file... How can I correcly read an ANSI
text-file?

Kind regards,

John


"Armin Zingler" <az*******@freenet.dewrote in message
news:uc**************@TK2MSFTNGP05.phx.gbl...
"John Devlon" <jo********@hotmail.comschrieb
>>
Hi,

I added the code below i'm using. I'm using an array instead of an
arraylist. It's not something i'm proud off, but it works...
Where do I have to add the encoding ?

John

Private arrContentFile() As String
Dim oFile As System.IO.File
Dim oRead As System.IO.StreamReader

Private Sub ReadfileTest(ByVal strFilename As String)
Dim intCount As Int64 = 0
Dim strLine As String

Dim objStreamReader = New System.IO.StreamReader(strFilename)

strLine = objStreamReader.ReadLine

Do While Not strLine Is Nothing
If Not (IsNothing(arrContentFile)) Then
intCount = arrContentFile.GetUpperBound(0) +
1 End If
ReDim Preserve arrContentFile(intCount)
arrContentFile(intCount) = strLine

strLine = objStreamReader.ReadLine
Loop

objStreamReader.Close()

End Sub


"Armin Zingler" <az*******@freenet.dewrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
"John Devlon" <jo********@hotmail.comschrieb
Hi,

Can anyone please help me?

I've wrote a small application that reads the content from a
text-file. Some characters are not displayed correcly.

I noticed the text-file uses different types of Accent Signs
(').

Is there some simple methode to replace all of them to just one
kind ?

thanx
You must use the correct encoding when reading from the file. When
creating a StreamReader pass the correct System.Text.Encoding
instance to it's constructor.
Armin

First, you should enable Option Strict.

Then, as written, the Encoding must be passed to the constructor of the
StreamReader:

Dim objStreamReader As New System.IO.StreamReader( _
strFilename, System.Text.Encoding.Default _
)

I don't know which encoding has been used to write the file, so you first
have to know this and replace "Default" by the encoding to be used.
Side notes:
- You can write "Do Until" instead of "Do While Not"
- The "Is" Operator is more straightforward than calling the IsNothing
function.
- Yes, you could have used an Arraylist. ;-) Or, in FW 2.0, a List(Of
String).

Armin

Aug 14 '07 #5
"Armin Zingler" <az*******@freenet.deschrieb:
Dim objStreamReader As New System.IO.StreamReader( _
strFilename, System.Text.Encoding.Default _
)

I don't know which encoding has been used to write the file, so you first
have to know this and replace "Default" by the encoding to be used.
Just for the information of the OP: 'Default' refers to the default Windows
ANSI codepage of the system, which is used by default in the Windows editor
on Windows XP, for example. If you do not specify any encoding in the
'StreamReader''s constructor, UTF-8 is assumed and used.

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

Aug 14 '07 #6
"John Devlon" <jo********@hotmail.comschrieb
Dear Mr. Zingler,

Thanx for your tips... it was very usefull....

But problem is getting more complex...

The files I'm trying to read are text-file, created in notepad,
using the ANSI encoding...
Resaving a file in notepad to UTF and adjusting the application
(encoding UTF) works great and solves the problem...

However, I can't resave every file... How can I correcly read an
ANSI text-file?
See Herfried's answer (System.Text.Encoding.Default).
Armin
Aug 14 '07 #7
Dear Mr. Zingler,

Your provided solutions works great... Like a charm...

Thank you very much

John
"Armin Zingler" <az*******@freenet.dewrote in message
news:OG**************@TK2MSFTNGP05.phx.gbl...
"John Devlon" <jo********@hotmail.comschrieb
>Dear Mr. Zingler,

Thanx for your tips... it was very usefull....

But problem is getting more complex...

The files I'm trying to read are text-file, created in notepad,
using the ANSI encoding...
Resaving a file in notepad to UTF and adjusting the application
(encoding UTF) works great and solves the problem...

However, I can't resave every file... How can I correcly read an
ANSI text-file?

See Herfried's answer (System.Text.Encoding.Default).
Armin

Aug 21 '07 #8

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

Similar topics

2
by: JB | last post by:
Hi, I'm having a problem with accent in PHP/HTML. I have a value stored in a table. The value is : é è à ù When I look directly into table via phpmyadmin, the value seems to be stored...
114
by: muldoon | last post by:
Americans consider having a "British accent" a sign of sophistication and high intelligence. Many companies hire salespersons from Britain to represent their products,etc. Question: When the...
3
by: Matthias HALDIMANN | last post by:
My SQL Server 2000 does not use the accent insensitive collation setting (collation containing _AI) in full-text serches: While SELECT * FROM <table> WHERE <column> LIKE '%a%' returns 'Mäuse',...
3
by: Darren Jensen | last post by:
Hi, Does anyone have a function which replaces accent chars from a string with the non-accented equivalent? For example 'hôpital' should return 'hopital'. Thank you in advance.
3
by: Daedalus.OS | last post by:
Hi, I've been asked to transfert a database from a webhoster to another. I think the database is on a windows box but I'm not 100% shure. The webhoster says it provides combined hosting on...
2
by: vinhat | last post by:
Hi, Is there any option / feature in DB2 database where one can retrieve data from the database by treating the accented / diacritic characters equivalent to their English characters. For...
1
by: Stan Sainte-Rose | last post by:
Hi, I have a problem when I use StreamReader.ReadToEnd. All the the accent characters are deleted.. I mean by accent characters : éééààà etc... Any idea ? Stan
1
by: Fabrice | last post by:
Hello, I have encountered a deep problem with accent and I don't understand why. I m preparing a multi-language website. French and English so far. With french, we have accents and ......
0
by: Fabrice | last post by:
Hello, (Alain) Tis is a part of my code to retrieve text from hastable in memory cache, by reading (befor) a resources file. Thanks for your help. /1/ The resources file * I have create a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
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
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
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...
0
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
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...
0
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,...
0
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...

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.