3

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.

4
  • 6
    What is "866-th encoding"? What is a symbox? Commented Feb 25, 2011 at 7:44
  • 1
    Hi, can you show the way you are using streamReader.Read() ? I think we should use an overload with specific encoding... Commented 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. Commented Nov 24, 2011 at 10:46
  • Hey, could you add the solution as an answer? Commented Dec 2, 2011 at 19:26

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

Comments

1

Hmmm. I think you should read file as binary file not as text file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.