Serializing CString without string length 
Author Message
 Serializing CString without string length

Is there a way to serialize CStrings without serializing their
length in the beginning of the string? I found that when
serializing CStrings, the first character of the string is the
length of the string. The file will be opened by a plain text
editor. That first character is really annoying. Is there a way
not to store that first character or do I have to resort to
fstream?


Sat, 19 Apr 2003 10:00:12 GMT  
 Serializing CString without string length

One of the ways it to use an archive. Something like this:

  CStdioFile theFile;

  if(!theFile.Open(fileName, CFile::modeWrite | CFile::typeText |
CFile::modeCreate))
  {
   TRACE("Cannot Open file\n");
   return;
  }

  CString RuleText(_T("Archive this CSTring"));
  CArchive archive(&theFile, CArchive::store);
  archive.WriteString(Ruletext);
  archive.Close();

--
Ajay Kalra [MVP - VC++]

Note: Please post all replies to newsgroup only.


Quote:
> Is there a way to serialize CStrings without serializing their
> length in the beginning of the string? I found that when
> serializing CStrings, the first character of the string is the
> length of the string. The file will be opened by a plain text
> editor. That first character is really annoying. Is there a way
> not to store that first character or do I have to resort to
> fstream?



Sat, 19 Apr 2003 10:42:48 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. serialize and zero length files: not calling serialize()

2. Question: CMap of strings without using CString

3. Question: CMap of strings without using CString

4. Using CString functionality without CString variable/cast operator

5. Using CString functionality without CString variable/cast operator

6. strings: length of strings

7. Newbie: CString, string, cstring

8. Passing sizes of arrays without a separate argument for the length

9. View CString length in debugger

10. CString Length

11. CString buffer length - how to increase and monitor?

12. CString max length?

 

 
Powered by phpBB® Forum Software