CString with non display characters
-
Hi, I have been having issues trying to use CString with non display characters e.g. X0A or nulls I now there is a constructer CString(LPCTSTR,int) which takes a length the contructer Doesn't take a pointer e.g. CString *mystr(str,20) Any help would be appreciated Thanks
-
Hi, I have been having issues trying to use CString with non display characters e.g. X0A or nulls I now there is a constructer CString(LPCTSTR,int) which takes a length the contructer Doesn't take a pointer e.g. CString *mystr(str,20) Any help would be appreciated Thanks
-
ForNow wrote:
Any help would be appreciated
What exactly are the issues you are having, your question does not make it clear.
The scenario is the following I have a shared storage pointer with my console application Hercules it is defined as LPVOID most of it is displayable characters but some are just hex characters When try to construct the string with the following CString constructer CString mystr((LPCTSTR) mysharedptr,34); tracing it in the visual studio debugger The code goes off into some MFC code that had an assertion specifically ASSERT(FALSE) Thanks
-
The scenario is the following I have a shared storage pointer with my console application Hercules it is defined as LPVOID most of it is displayable characters but some are just hex characters When try to construct the string with the following CString constructer CString mystr((LPCTSTR) mysharedptr,34); tracing it in the visual studio debugger The code goes off into some MFC code that had an assertion specifically ASSERT(FALSE) Thanks
Show the function and the ASSERT where it goes.
The difficult we do right away... ...the impossible takes slightly longer.
-
The scenario is the following I have a shared storage pointer with my console application Hercules it is defined as LPVOID most of it is displayable characters but some are just hex characters When try to construct the string with the following CString constructer CString mystr((LPCTSTR) mysharedptr,34); tracing it in the visual studio debugger The code goes off into some MFC code that had an assertion specifically ASSERT(FALSE) Thanks
-
Sorry but you are still not giving us any useful information. What exactly is the content of
mysharedptr
, and what assertion are you getting? It may well be that aCString
is just the wrong class for whatever problem you are trying to solve. -
Richard I had a religious holiday over the last 2 days I do have non display hex characters in the CString I am begining to think that even though there is a constructer for CString that takes a length it Still is just that a Csting a C type string
CString holds strings. C-type strings. if you need a container to hold chunks of data which might contain a NULL, CString is the wrong container. you can use a
std::vector< BYTE >
(or a CByteArray, if you like MFC). or you can roll your own. -
Richard I had a religious holiday over the last 2 days I do have non display hex characters in the CString I am begining to think that even though there is a constructer for CString that takes a length it Still is just that a Csting a C type string
As Chris mentioned, think you're trying to use CString for something it's not intended to do. If you need a random byte container (that isn't a string), use something else. STL has a quite a few to choose from[^]. Additionally, other libraries have other choices... http://www.boost.org/doc/libs/?view=category_Containers[^]
-
As Chris mentioned, think you're trying to use CString for something it's not intended to do. If you need a random byte container (that isn't a string), use something else. STL has a quite a few to choose from[^]. Additionally, other libraries have other choices... http://www.boost.org/doc/libs/?view=category_Containers[^]
-
Well, most data comes down to being bytes... strings just are some set of bytes that are expected to mean something (whether according to ASCII or some other wide character standard)... if you need a generic container, you can't just use something that expects what we'd refer to as a "string".