rileo8
asked on
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???
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???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you have a code sample that you can post, so we can see how you are doing it.
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
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