cancel
Showing results for 
Search instead for 
Did you mean: 

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

LeonSu
Associate II

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

 

1 REPLY 1
JTP1
Lead

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