Sunday, 15 April 2012

File write with Encoding in C++ Builder -



File write with Encoding in C++ Builder -

my environment: radstudio xe4 update1 on windows7 pro (32bit).

when want write file encoding, apis?

i found tstreamwriter.create(filename, ..., tencoding.getencoding(...)) 1 option. used normally?

i found tstringlist.savetofile() encoding.

i tried find way specify encoding fileopen()/filewrite(), did not find related information.

there assignfile function. xe has optional codepage parameter sets codepage of output file (see http://stackoverflow.com/a/14243866/3235496).

also tstringstream::create method accepts tencoding parameter. while tstringlist line-oriented, tstringstream class useful read/write string blob (see http://stackoverflow.com/a/6397914/3235496).

these should cover many typical utilize cases.

fileopen() / filewrite() lower-level file access routines. embarcadero doesn't encourage utilize of non-native delphi language file handlers , normal file operations suggest assignfile, rewrite , reset instead.

edit

anyway i'd remain tstringstream / tstringlist solution if possible.

c++ file-io character-encoding c++builder

No comments:

Post a Comment