Skip to main content
Associate II
August 19, 2025
Solved

The text area cannot display correctly when the user inputs a character array.

  • August 19, 2025
  • 2 replies
  • 569 views

Hello every,

I created some text areas to display the file name, which comes from a character array provided by the user's input.

 

 

Below are the configuration settings for each text area.

1.text area

LeonSu_0-1755581922664.png

2.Texts->Typographies

LeonSu_1-1755582073775.png

 

3.code

3.1.text area define in class

 touchgfx::TextAreaWithOneWildcard data06_text;
 touchgfx::TextAreaWithOneWildcard data05_text;
 touchgfx::TextAreaWithOneWildcard data04_text;
 touchgfx::TextAreaWithOneWildcard data03_text;
 touchgfx::TextAreaWithOneWildcard data02_text;
 touchgfx::TextAreaWithOneWildcard data01_text;
 static const uint16_t DATA06_TEXT_SIZE = 32;
 touchgfx::Unicode::UnicodeChar data06_textBuffer[DATA06_TEXT_SIZE];
 static const uint16_t DATA05_TEXT_SIZE = 32;
 touchgfx::Unicode::UnicodeChar data05_textBuffer[DATA05_TEXT_SIZE];
 static const uint16_t DATA04_TEXT_SIZE = 32;
 touchgfx::Unicode::UnicodeChar data04_textBuffer[DATA04_TEXT_SIZE];
 static const uint16_t DATA03_TEXT_SIZE = 32;
 touchgfx::Unicode::UnicodeChar data03_textBuffer[DATA03_TEXT_SIZE];
 static const uint16_t DATA02_TEXT_SIZE = 32;
 touchgfx::Unicode::UnicodeChar data02_textBuffer[DATA02_TEXT_SIZE];
 static const uint16_t DATA01_TEXT_SIZE = 32;
 touchgfx::Unicode::UnicodeChar data01_textBuffer[DATA01_TEXT_SIZE];

 

3.2.display the file name

void selectFileScreenView::SendOpenFileTitle(const uint16_t index, const char *title)
{
	//Debug_Printf("title:%s", title);
	switch(index){
	case 0:
		Unicode::snprintf(data01_textBuffer, DATA01_TEXT_SIZE, "%s", title);
		data01_text.invalidate();
		break;
	case 1:
		Unicode::snprintf(data02_textBuffer, DATA02_TEXT_SIZE, "%s", title);
		data02_text.invalidate();
		break;
	case 2:
		Unicode::snprintf(data03_textBuffer, DATA03_TEXT_SIZE, "%s", title);
		data03_text.invalidate();
		break;
	case 3:
		Unicode::snprintf(data04_textBuffer, DATA04_TEXT_SIZE, "%s", title);
		data04_text.invalidate();
		break;
	case 4:
		Unicode::snprintf(data05_textBuffer, DATA05_TEXT_SIZE, "%s", title);
		data05_text.invalidate();
		break;
	case 5:
		Unicode::snprintf(data06_textBuffer, DATA06_TEXT_SIZE, "%s", title);
		data06_text.invalidate();
		break;
	default:
		break;

	}
}

 

4.result

00001.jpg

I’m sure that the const char *title is correct, but all the text areas display "???????????". Please help me fix this. Thanks in advance

 

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

Hello Leon Su

I think Unicode::snprintf expects that the printed string ('title' in your case) should be at Unicode format (16 bit). 

Try to use unicode::fromUTF8 instead. 

Something like

Unicode::fromUTF8(title,data01_texyBuffer,DATA01_TEXT_SIZE);

 Hope this helps.

br JTP

2 replies

JTP1Best answer
Graduate II
August 19, 2025

Hello Leon Su

I think Unicode::snprintf expects that the printed string ('title' in your case) should be at Unicode format (16 bit). 

Try to use unicode::fromUTF8 instead. 

Something like

Unicode::fromUTF8(title,data01_texyBuffer,DATA01_TEXT_SIZE);

 Hope this helps.

br JTP

LeonSuAuthor
Associate II
August 20, 2025

thaks @JTP1 

It works perfectly. Thank you again!