Skip to main content
Associate III
August 16, 2023
Solved

Convert UnicodeChar to const char

  • August 16, 2023
  • 2 replies
  • 1670 views

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

This topic has been closed for replies.
Best answer by JTP1

Hello

Perhaps this way:

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

Br J.T

 

2 replies

JTP1Best answer
Graduate II
August 16, 2023

Hello

Perhaps this way:

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

Br J.T

 

mids400Author
Associate III
August 17, 2023

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