By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,312 Members | 1,900 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,312 IT Pros & Developers. It's quick & easy.

Converting from System::String to std::string while keeping nulls.

P: n/a
Hi,
I am using Visual C++ in Visual Studio 2005 to create a Managed Wrapper
around some C++ LIBS. I've created some classes that contains a pointer to
the LIB classes and everthing seems to compile well.
The problem is getting a std::string from System::String and still
preserving the nulls. System::String is a base64 encoded string of a series
of bytes. When I convert it back to a string from base64 representation, the
NULLs inside the decoded string makes it smaller. Suppose the decoded string
is $BFGDHF\0GDFS, I get $BFGDHF and the NULL char is interpretted as
termination char. But I need to get a string with all the nulls and data.

thanks

Jul 24 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Abhimanyu Sirohi" <Ab*************@discussions.microsoft.comwrote in
message news:9C**********************************@microsof t.com...
Hi,
I am using Visual C++ in Visual Studio 2005 to create a Managed Wrapper
around some C++ LIBS. I've created some classes that contains a pointer to
the LIB classes and everthing seems to compile well.
The problem is getting a std::string from System::String and still
preserving the nulls. System::String is a base64 encoded string of a
series
of bytes. When I convert it back to a string from base64 representation,
the
NULLs inside the decoded string makes it smaller. Suppose the decoded
string
is $BFGDHF\0GDFS, I get $BFGDHF and the NULL char is interpretted as
termination char. But I need to get a string with all the nulls and data.
Use the std::string constructor that takes a pair of iterators rather than
the one that takes a (w)char*. You can supply pointers to the begining and
one-past-the-end of the buffer containing the decoded bytes as the
"iterators" for the constructor.

-cd
Jul 24 '07 #2

P: n/a
use bytes[] instead of strings.

--
Sheng Jiang
Microsoft MVP in VC++
"Abhimanyu Sirohi" <Ab*************@discussions.microsoft.comwrote in
message news:9C**********************************@microsof t.com...
Hi,
I am using Visual C++ in Visual Studio 2005 to create a Managed Wrapper
around some C++ LIBS. I've created some classes that contains a pointer to
the LIB classes and everthing seems to compile well.
The problem is getting a std::string from System::String and still
preserving the nulls. System::String is a base64 encoded string of a
series
of bytes. When I convert it back to a string from base64 representation,
the
NULLs inside the decoded string makes it smaller. Suppose the decoded
string
is $BFGDHF\0GDFS, I get $BFGDHF and the NULL char is interpretted as
termination char. But I need to get a string with all the nulls and data.

thanks

Jul 24 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.