cancel
Showing results for 
Search instead for 
Did you mean: 

Convert UnicodeChar to const char

mids400
Associate III

Hello everyone,

I would be mentioned this topic here which is the same.

I am using KeyboardWidget of TouchGFX in my project and need to print the value from keyboard.getBuffer() into a const char to draw it again in QRCode.

I have tried all the ways but no result and got some errors.

char QRBuffer[20];

void MainView::CreateClicked()
{
    // Show the entered text in the text box on the display
    Unicode::strncpy(textAreaQRBuffer, keyboard.getBuffer(), TEXTAREAQR_SIZE);
    // Copy the entered text into the char string to drawing QRCode
    Unicode::snprintf(QRBuffer, sizeof(QRBuffer), "%d", textAreaQRBuffer);
    // Drawing the QRCode
    CreateQR();
}

I have used strncpy but also no way! I have tried to casting the buffer value like this but also not working:

char* QRBuffer = (char*)textAreaQRBuffer;

Any suggestions?

Thanks, Mahdi

1 ACCEPTED SOLUTION

Accepted Solutions
JTP1
Lead

Hello

Perhaps this way:

Unicode::toUTF8(textAreaQRBuffer, (uint8_t *)QRBuffer, sizeof(QRBuffer));

Br J.T

 

View solution in original post

2 REPLIES 2
JTP1
Lead

Hello

Perhaps this way:

Unicode::toUTF8(textAreaQRBuffer, (uint8_t *)QRBuffer, sizeof(QRBuffer));

Br J.T

 

Perfect, Its worked 100%..

Actually i have tried it before but i have not casted the value of QRBuffer as unsigned int thats why i had many errors.

Thanks.. Mahdi