Sign in to follow this  
Riviera Kid

[.net] convert string to char array (mc++/cli)

Recommended Posts

System::String^ s = "DeviceInfo"; array<wchar_t,1>^ unicodeArray = s->ToCharArray(); array<unsigned char,1>^ charArray= System::Convert::FromBase64CharArray(unicodeArray ,0 /*offset*/,unicodeArray ->Length); compiles without warnings. No casting required. Length returns 10. Error: Invalid length for a Base-64 char array. im lost, this should work as far as i can see. Anybody any ideas?

Share this post


Link to post
Share on other sites
The problem is that your unicodeArray is not a base 64 char array (uuencoded). A true base 64 char array must be a multiple of 4 bytes long and have base 64 characters in it. A standard System::String doesn't have base 64 characters.

I'm not sure I understand what you are trying to do. If all you want to do is convert a System::String to an array of characters (System::Char[]), all you need is the ToCharArray().

Share this post


Link to post
Share on other sites
yeah, your right, oops.

However i know i can convert to a character array with ToCharArray() but that returns a unicode 16 bit character.

There are infact file write methods which take 8 bit byte streams. How do i convert to 8 bit characters?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this