Converting from char[] to tstring

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wfroelich
    New Member
    • Jan 2010
    • 1

    Converting from char[] to tstring

    I have an application where I am querying a modem over a tcp socket. I can receive the data from the modem as expected into my char[1024] buffer but am having trouble then converting it to a tstring.

    I am seeing some extra characters returning now (after a firmware upgrade) that I suspect are multi-byte characters which then screwup my checking routines.

    Here is what I am doing currently

    retString = (std::tstring)( (CString) recvBuf);

    is there a better way to ensure if multi-byte characters are in the buffer they are handled correctly?
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    Hi,
    I am not sure whether I have understood you.

    But about multibyte data how do you know that they are multibyte. another thing is whether they are multibyte or not you will get them as single byte(8 bit). The reason is you have defined buffer as char (signed byte). if you have "私" char. Shift-JIS will return 2 bytes for it and char buffer will store this two bytes as two different bytes. not only this I know these bytes will be meaningful if i use Shift-JIS encoding only not any other encoding.

    Let us know if you know anything about these or if I am wrong.

    Best regards,
    Johny

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Code:
      retString = (std::tstring)((CString) recvBuf);
      Tell me again how this cast converts a recvBuf (whatever type that is) to a CString that is then converted to a tstring?

      Also, tell me how tstring is part of the std namespace.

      If you can do that, your question will be answered.

      Comment

      Working...