473,499 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting from char[] to tstring

1 New Member
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?
Jan 21 '10 #1
2 6332
johny10151981
1,059 Top Contributor
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
Jan 22 '10 #2
weaknessforcats
9,208 Recognized Expert Moderator Expert
Expand|Select|Wrap|Line Numbers
  1. 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.
Jan 22 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
5356
by: Prabhu | last post by:
Hi, We are having problem in converting a byte array to string, The byte array has char(174), char(175), char(240), char(242) and char(247) as delimiters for the message. when we use...
4
3734
by: goldfita | last post by:
My last post - http://groups.google.com/group/comp.lang.c/browse_thread/thread/eacc2938b4c8ee66/0bdf6ab20a6007d0 I have a little bit more challenging question this time. Suppose I have ...
9
30475
by: Gregory.A.Book | last post by:
I am interested in converting sets of 4 bytes to floats in C++. I have a library that reads image data and returns the data as an array of unsigned chars. The image data is stored as 4-byte floats....
0
2009
by: anide | last post by:
Hi all I’ve some problem, I’m trying to converting a sorting algorithm from C++ to C#. In C++ I’ve compiled it using MSVC and its working properly, and in C# I’m using .NET Framework 2.0 (Visual...
15
9638
by: allthecoolkidshaveone | last post by:
I want to convert a string representation of a number ("1234") to an int, with overflow and underflow checking. Essentially, I'm looking for a strtol() that converts int instead of long. The...
2
1783
by: zmy12007 | last post by:
what different bettwen const tstring& str and tstring str as paramenter
1
3781
by: vcbytes | last post by:
I am having a problem with the following code: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { String^ texts = textBox1->Text; char *text =...
12
6581
by: kevin.eugene08 | last post by:
Hello all, Forgive the somewhat simple question I am sure this will be, but I am having some problem understanding what: char **argv looks like. For instance, i know through trial and error...
12
5960
by: Jrdman | last post by:
hi, in some function prototypes why they use const char* instead of const char what's the need for const here is? if we must use const and why they don't use char *const instead because it's...
4
3583
by: screamer81 | last post by:
Hello, I've a SDK functions description for a scanner and I try to convert unmanaged DLL C++ functions to c#. I converted all except one of them. This function is getting a struct parameter. ...
0
7131
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5470
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4600
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3099
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
297
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.