UK Currency Symbol and Text File Stream Problems

  • Thread starter Thread starter Paul [Paradise Solutions]
  • Start date Start date
P

Paul [Paradise Solutions]

Hi All

In a console app I have the following code:

Sub Main()
Dim p_CustomerLine As String
Dim stream As IO.StreamReader = IO.File.OpenText("c:\test.txt")
Do
p_CustomerLine = stream.ReadLine()

If Not p_CustomerLine Is Nothing Then
Console.WriteLine(p_CustomerLine)

End If

Loop Until p_CustomerLine Is Nothing
End Sub


... And it works grand, lines get read in and displayed as they
should.... with the exception of the UK curreny symbol (£).

I'd be very grateful if anyone could explain to me why ReadLine strips
them out of anything it reads in.


Many thanks


Paul
 
Paul said:
In a console app I have the following code:

Sub Main()
Dim p_CustomerLine As String
Dim stream As IO.StreamReader = IO.File.OpenText("c:\test.txt")
Do
p_CustomerLine = stream.ReadLine()

If Not p_CustomerLine Is Nothing Then
Console.WriteLine(p_CustomerLine)

End If

Loop Until p_CustomerLine Is Nothing
End Sub


.. And it works grand, lines get read in and displayed as they should....
with the exception of the UK curreny symbol (£).

I'd be very grateful if anyone could explain to me why ReadLine strips
them out of anything it reads in.

Take a look at the overloaded versions of 'StreamReader''s constructor. At
least one overload expects an encoding. Try to pass 'Encoding.Default' to
read the file with the system's default codepage.
 
Outstanding - thanks for that, thought I was going doo-lally!


Many thanks


Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top