Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pound sign (£) not displaying correctly 1

Status
Not open for further replies.

jonnyknowsbest

Technical User
Joined
Feb 3, 2004
Messages
163
Location
GB
I have written a small app that outputs from a richtextbox to a text file. It all works fine, apart from when i want to output the british pound sign (£). When i try to view this text file, the pound sign is preceded by a capital A with a caret above it.

If i look at the file in hex, the pound sign is C2 A3, but if i create a text file in Notepad, the pound sign is just A3.

Where is the C2 coming from and how do i stop it?
 
The file is being output in UTF-8 unicode. Use the GetEncoding method on the Encoding class to get an Encoding object for Windows-1252 code page, and pipe your output through it.
Code:
Dim enc as Encoding = Encoding.GetEncoding("windows-1252")
Dim ub as Byte() = Encoding.Unicode.GetBytes(yoursourceString)
Dim wb as Byte() = Encoding.Convert(Encoding.Unicode, enc, ub)
yourfileStream.Write(wb, 0, wb.Length)
Chip H.

____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top