large CString problem

I have a custom resource that contains a html file of 32KB.

I need to:

- copy it into a Cstring
- replace some characters
- save it to a file

But i'm experiencing some problems because seems thata only a part of the html file is saved into the CString...

what's wrong???
rileo8Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZoppoCommented:
Hi rileo8,

IMO this shouldn't be a problem with the size of the CString - I think a CString's length can be (theoretically) MAX_INT - 1.

I guess the problem is somewhere else in your code - could you post the code you're using?

ZOPPO
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sarabandeCommented:
your last question about reading the html resource was not yet closed. did you come further?

you seemed to have used code from http://www.codeproject.com/KB/cpp/GetHTML.aspx and it is not quite clear whether your current question is related to that.  

check your project properties whether there is UNICODE enabled or not. if it is enabled the CString is based on WCHAR (== wchar_t) type what is a two-byte "wide" character. if you have "Multibyte Character Set" enabled, the CString is based on char type.

if you read the resource with LoadResource and get a pointer by LockResource, the pointer needs to be casted to LPCTSTR what is 'long constant pointer to TCHAR string', what means that it also either points to wide char buffer (UNICODE) or char buffer (Multibyte).

the code from codeproject is already considering that.

how much data did you get from the html file? is it possible that the html contains some binary data? the problem with that might be that binary data likely contains binary zero characters which are regarded as terminators when you assign them to a CString. so a statement like

rString = CString(lpcHtml);

Open in new window


would fail in determining the correct length of the html if it contains zero characters. if that could be the case you need to change the html before you can read it into a CString.

another idea that came to my mind is that the CString could contain linefeed characters and because of that you only see parts of the html in the debugger. try to use AfxMessageBox or OutputDebugString to show the CString. that would correctly show a multi-line string.

Sara
0
ajones2600flCommented:
Do you have a code sample that you can post, so we can see how you are doing it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.