asp.net - Fix Special Characters in String -
I have found a program that briefly reads values from a SQL database and writes them in a tab-delimited text file is .
The issue is that some values in the database are special characters (tm, dash, alipsis etc.), when the text file is written, the formatting is lost and they are junk "one" ¢ or â € "Etc."
When the value is seen in the instant window, before it is written on the txt file, everything looks fine. My guess is that it is an encoding issue but, I am not sure How to move forward, where to see or what to see
Is this ASCII or UTF-8? If this is one of those people, then how can I fix this before writing it in a text file.
Here's how I create a text file (where feedStr is a stringbilder)
objReader = new streamer (file path) objReader.Write (feedStr) objReader.Close ( ) The default encoding for StreamWriter is UTF8 (without the bit sequence symbol).
Your result file is fine, the question is, what do you open it later? If you open it in a UTF 8 enabled text editor, then the letters should look like the way you want it.
You can also type text files in other encodings, for example ISO-885 9-1 (Latin 1)
objReader = new streamer (file path, incorrect , Encoding.NET encoding ("ISO-885 9-1"))
Comments
Post a Comment