Char from string for dummies


I’m sad to ask you that, but I don’t know how to do that.
I got a TextEditor I wanna send the Char of the string one by one
String str = editText.getText(); //return the string it's OK

I wanna use something like
sysexdata[8] = myChar[i];
How can I have the Char of my string one by one ?

I guess I need to use this, but how ?
String::toRawUTF8 ( )


String temp = editText.getText();
const char* strraw = temp.toRawUTF8();
for (…blah…)

I suppose you could also simply try casting to an 8 bit char from the String’s operator result.


YES ! Thanks a lot ! Really stupid I am !
I was making this:
String str = editText.getText();
uint8 sysexdata[9] = { 0x43, 0X10, 0x34, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00 };
MemoryBlock mb(str.toRawUTF8( ), str.getNumBytesAsUTF8( ) + 1);
for (auto i=0; i<10; i++) {
sysexdata[8] = mb[i];


Note that I edited the answer above to be more correct. There annoyingly probably needs to be that temp String involved.


I believe you could get away with a one liner like this:

startIndex and numBytesToFill are values you should provide depending upon the area of the buffer that you want to fill:

editText.getText().copyToUTF8 (sysexdata + startIndex, numBytesToFill)