Working With Strings

String Special Characters sTemp += "\r\n" //Add a newline String ^sTemp = = "\x7"; // ‘\x’ means ‘0x’ and the 1 of 2 digits that follow are a hex value for the character requried newline( LF) \n horizontal tab (TAB) \t vertical tab \v backspace \b carriage return (CR) \r formfeed \f alert (bell) \a […]

Read More

Convert Bytes To A String

array<Byte> ^RxData = gcnew array<Byte>(2); RxData[0] = 'A'; RxData[0] = 'B'; String ^sTemp; sTemp = System::Text::Encoding::UTF8->GetString(RxData); N.B. Make the array the length of the string – do not use a 0x00 terminating byte. If you do you get a resulting string but you can't add any new characters to it (e.g. MyString += "abc") because […]

Read More

Convert String To Byte Array

String Direct To Byte Array String ^sTemp; array<Byte> ^TxData; sTemp = “Hello”; TxData = System::Text::Encoding::UTF8->GetBytes(sTemp); Lengthy Method String ^Filename; Filename = “HELLO.TXT”; array<Char> ^NameArray = Filename->ToCharArray(); Array::Resize(NameArray, 13); //If you need to ensure a minimum size use this TxData[ByteId++] = Convert::ToByte(NameArray[0]); TxData[ByteId++] = Convert::ToByte(NameArray[1]); TxData[ByteId++] = Convert::ToByte(NameArray[2]); TxData[ByteId++] = Convert::ToByte(NameArray[3]); TxData[ByteId++] = Convert::ToByte(NameArray[4]); TxData[ByteId++] = […]

Read More

Arrays of Strings

Creating String Arrays Different ways to create string arrays: array<String^> ^myArray = gcnew array<string^>(10); //or array<String^> ^myArray; myArray = gcnew array<String^>(10); //or array<String^> ^myArray = {"channel8" "channel9", "technet" , "channel10", "msdn"}; Calling a function with an array of constant strings MyFunction((gcnew array {"Monday", "Tuesday", "Wednesday"}); Getting each entry from a list of strings array ^ports; […]

Read More