I have file in cp866 encoding. In some places it's file contains symbol 0 in hex code. When I try to read this file with File.ReadAllText() or streamReader.Read() it's stop reading file in this symbol. How to solve this problem?
[UPDATE]
I think that symbol 0x0 means end of file.
-
6What is "866-th encoding"? What is a symbox?Oded– Oded2011-02-25 07:44:35 +00:00Commented Feb 25, 2011 at 7:44
-
1Hi, can you show the way you are using streamReader.Read() ? I think we should use an overload with specific encoding...Davide Piras– Davide Piras2011-02-25 07:44:43 +00:00Commented Feb 25, 2011 at 7:44
-
please post your solution as an answer and accept that answer to remove this question from the unanswered list.Code Magician– Code Magician2011-11-24 10:46:22 +00:00Commented Nov 24, 2011 at 10:46
-
Hey, could you add the solution as an answer?user1228– user12282011-12-02 19:26:51 +00:00Commented Dec 2, 2011 at 19:26
Add a comment
|
2 Answers
Are you looking for something like this?
Encoding encoding = Encoding.GetEncoding(866);
string text = File.ReadAllText("foo.txt", encoding);
That assuming you want code page 866.
I don't know enough about CP866 to know whether it would normally contain 0 bytes... but if your text file is valid CP866, the above should read it.