2021-04-29 07:59 AM
Hi,
I'm trying to print the string. What is that I'm missing?
This is my func :
void Screen1View::UpdateWildcardTexts(char* a)
{
Unicode::snprintf(textArea1Buffer,10,"%s",a);
textArea1.invalidate();
}
This is how I test it :
void Screen1View::setupScreen()
{
Screen1ViewBase::setupScreen();
char a[16] = "string";
UpdateWildcardTexts(a);
}
Solved! Go to Solution.
2021-04-29 02:21 PM
touchgfx::Unicode::snprintf only supports the %s format with UnicodeChar arguments. You should use touchgfx::Unicode::strncpy instead to fill the buffer with your char array.
touchgfx::Unicode::strncpy(textArea1Buffer, a, 10);
If you really want to use snprintf, convert it to a UnicodeChar first.
void Screen1View::UpdateWildcardTexts(const char* a)
{
touchgfx::Unicode::UnicodeChar b[10];
touchgfx::Unicode::strncpy(b, a, 10);
touchgfx::Unicode::snprintf(textArea1Buffer,10,"%s",b);
textArea1.invalidate();
}
Sidenote: @Martin KJELDSEN I see that anchor links in tgfx documentation still don't work =)
2021-04-29 02:21 PM
touchgfx::Unicode::snprintf only supports the %s format with UnicodeChar arguments. You should use touchgfx::Unicode::strncpy instead to fill the buffer with your char array.
touchgfx::Unicode::strncpy(textArea1Buffer, a, 10);
If you really want to use snprintf, convert it to a UnicodeChar first.
void Screen1View::UpdateWildcardTexts(const char* a)
{
touchgfx::Unicode::UnicodeChar b[10];
touchgfx::Unicode::strncpy(b, a, 10);
touchgfx::Unicode::snprintf(textArea1Buffer,10,"%s",b);
textArea1.invalidate();
}
Sidenote: @Martin KJELDSEN I see that anchor links in tgfx documentation still don't work =)
2021-04-29 11:16 PM
Thank you for your answer. I tried to use strncpy(), but I got fallback character even I wrote A-Z into Wilcard Ranges. Now I just wrote a-z into Wilcard Ranges and I could see the "string".