c# - Smart ASCII string representation -


I have an app that converts binary file into ASCII file. With profiler I came to know that I am encoding 25%. Getbytes () which are written from BinaryWriter. White (wchar []). This is completely true because I have many such structures:

  m_writer.Write ("some fancy long text". ToCharArray ());  

Do you have any smart ideas to avoid this encoding conversion?

Now I would like to think of something like this:

  byte byte [] SOME_FANCY_LONG_TEXT = encoding ASCII.GetBytes ("Some fancy ..."); // ... and later m_writer.Write (SOME_FANCY_LONG_TEXT);  

But I have several entries to do this manually.

If you are creating a text file, you can use the BinaryWriter Why do Just use a TextWriter BinaryWriter is for binary streams where you want to type preferences, strings etc. in a simple way.

(Are all of your text definitely going to be ASCII, by the way? You may want to consider using UTF-8 instead.)


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -