Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 864
Product
FileManager
Version
All
Title
File Manager doubles the size of text files
Problem
When using a BinaryStream to write a text file, the size of the file created is twice as large as expected.
Solution

This behavior is not a bug, but rather a result of writing out binary text data in UTF-16 encoding. This is necessary to preserve line breaks and other special characters that may be contained in the text. The expectation is that the text will be written at a ratio of 8 bits per-character, as in normal ASCII encoding. This is not the case, as UTF-16 uses 16 bits per-character, effectively doubling the size of the outputted text file.

In order to generate text files that are 8 bits per-character, you should use the CreateTextFile or OpenTextFile methods in order to return a TextStream object. When using CreateTextFile, you must set the Unicode property to False.

CreateTextFile ([in] Name, [in] OverWrite, [in] Unicode)

When using OpenTextFile, you must set the Format property to TriStateFalse or -1.

OpenTextFile ([in] Filename, [in] IOMode, [in] Create, [in] Format)

Either method will then write to the file in ASCII encoding. You must be sure that there will be no characters that are not in the ASCII character set, or they will not be written properly in the outputted file.

Created : 9/21/2004 7:08:14 PM (last modified : 9/21/2004 7:09:08 PM)
Rate this article!
 
Comments