binary 00-FF....... (sometimes as many as 200k bytes)
binary 00-FF....... (sometimes as many as 200k bytes)
binary 00-FF....... (sometimes as many as 200k bytes)
binary 00-FF....... (sometimes as many as 200k bytes)
The binary sections can vary from 20k to 200k in size.
into separate strings to work with later in the application.
On 12/24/2010 10:47 PM, Joseph M. Newcomer wrote:
On Fri, 24 Dec 2010 18:29:46 -0500, Ed<me@right.her> wrote:
See within...
==========================================================================================
On 12/24/2010 6:01 PM, Joseph M. Newcomer wrote:
CStrings are counted byte arrays and you can use embedded NUL characters, but you cannot
use a lot of common string functions on them. But then again, the question is why you
would have embedded NUL characters, a constraint that was not part of your original
question.
==========================================================================================
This is the closest explanation of what I need
For example, "I have a sequence of bytes which I wish to copy to a workspace, manipulate,
and copy back into the same space, and the copy-back is conditional, which is why I need
to work on a copy. My sequence of bytes can contain embedded NUL bytes, and is otherwise
treated as a sequence of 8-bit characters in an application which is potentially Unicode.
I am using VS6" would have been a reasonable question.
===========================================================================================
Except I am not concerned with unicode.
****
Then the non-existence of CStringA will make no difference whatsoever, because if you
never use Unicode, all CStrings are 8-bit characters in VS6 (which is, by the way, the
default build model in VS6)
The embedded NUL characters make it more of a problem, because they require a great deal
of care to handle. Now, the question arises, why are they there at all?
Note that a normal text file has a CR LF sequence at the end of every line, and depending
on your expected file size, I would recommend simpley creating a CStringArray of lines,
or, for better performance, a std::vector<CString>, with one line per element, so you need
to say more about the kind of manipulations you need to do; for example
void DoSubstitute(CString& s)
{
CString workingCopy(s);
...do a bunch of stuff, e.g.,
workingCopy.Replace("X", "abc");
if(somecondition)
s = workingCopy;
}
where you pass in a reference to the string in the array.
This works as long as you don't need computations that cross line boundaries; then life
gets more complicated.
Next, the question is why the NUL characters? Can you eliminate them? For example, in
one case, I replaced all 0x00 bytes in a byte sequence with 0xFF, which was a character
that could never appear in the text (which was limited to ASCII-7) and therefore was not
going to be found. I replaced all but the last NUL character, so I now had a string with
no embedded NULs. There are characters in the range 0x7F..0xA0 that can be used if you
need the y-umlaut (code 0xFF in ISO-8859-1). Then, before writing the file back out, I
replaced all the 0xFF characters with 0x00. Saved a lot of trouble. The problem was a
really bad file format, by the way.
So again, you need to say more about the nature of the problem before it is possible to
give a meaningful answer.
*****
Or, "I have a sequence of 8-bit
characters which can have embedded NUL characters; I need to manipulate using standard
string functions on the substrings. For reasons too complex to explain here, I need to
work on a copy because I can be adding or deleting characters from the sequence
conditionally, and I will need to write it back into the same starting point as the
original, in spite of the change in length. I willl be using files whose size will not
exceed 1MB, and I'm using VS6, and [the application is otherwise Unicode] | [the
application in general might become a Unicode app]"
It would be possible to give meaningful answer to either of the previous questions, but
your question is not answerable as stated.
joe
On Fri, 24 Dec 2010 18:53:43 -0000, "David Webber"<dave@musical-dot-demon-dot-co.uk>
wrote:
"Ed" wrote in message news:T7ydndmFdYfgXonQnZ2dnUVZ_vednZ2d@giganews.com...
I cannot use CStringA in VC6
I know I cannot use CString with 0x00's in it.
I know all the file's I will be working contain only 8bit unsigned char's.
A string containing 0-byte is not a 'string'; it is an array of bytes.
Strings are terminated by 0-bytes.
You'll have to manage it as an array as Scott says.
Dave
-- David Webber
Mozart Music Software
http://www.mozart.co.uk
For discussion and support see
http://www.mozart.co.uk/mozartists/mailinglist.htm
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm