Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CString with non display characters

CString with non display characters

Scheduled Pinned Locked Moved C / C++ / MFC
help
10 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • F ForNow

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      ForNow wrote:

      Any help would be appreciated

      What exactly are the issues you are having, your question does not make it clear.

      F 1 Reply Last reply
      0
      • L Lost User

        ForNow wrote:

        Any help would be appreciated

        What exactly are the issues you are having, your question does not make it clear.

        F Offline
        F Offline
        ForNow
        wrote on last edited by
        #3

        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

        Richard Andrew x64R L 2 Replies Last reply
        0
        • F ForNow

          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

          Richard Andrew x64R Offline
          Richard Andrew x64R Offline
          Richard Andrew x64
          wrote on last edited by
          #4

          Show the function and the ASSERT where it goes.

          The difficult we do right away... ...the impossible takes slightly longer.

          1 Reply Last reply
          0
          • F ForNow

            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

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            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 a CString is just the wrong class for whatever problem you are trying to solve.

            F 1 Reply Last reply
            0
            • L Lost User

              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 a CString is just the wrong class for whatever problem you are trying to solve.

              F Offline
              F Offline
              ForNow
              wrote on last edited by
              #6

              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

              C A 2 Replies Last reply
              0
              • F ForNow

                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

                C Offline
                C Offline
                Chris Losinger
                wrote on last edited by
                #7

                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.

                image processing toolkits | batch image processing

                1 Reply Last reply
                0
                • F ForNow

                  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

                  A Offline
                  A Offline
                  Albert Holguin
                  wrote on last edited by
                  #8

                  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[^]

                  F 1 Reply Last reply
                  0
                  • A Albert Holguin

                    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[^]

                    F Offline
                    F Offline
                    ForNow
                    wrote on last edited by
                    #9

                    I am begining to see that CString is a "C" string Thanks

                    A 1 Reply Last reply
                    0
                    • F ForNow

                      I am begining to see that CString is a "C" string Thanks

                      A Offline
                      A Offline
                      Albert Holguin
                      wrote on last edited by
                      #10

                      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".

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups