Skip to main content
CPaye.1
Associate III
June 23, 2021
Solved

C++ Strings Interpreted As Fallback Characters

  • June 23, 2021
  • 2 replies
  • 794 views

I am using TGX v4.16.0. All of the work I describe with is with the TGX simulator in MSVS.

I am building native C++ strings from C character arrays. I am then taking these strings and using them to update a single wildcard text area. Most of the text is displayed correctly but some of the characters are interpreted as the fallback character (?). I am using a standard English language font. The characters that trigger the fallback character are in the range of A - Z. I have verified that the C++ string is being built correctly and that the wildcard buffer is big enough to hold the string.

Here is a part of the code and the result.

Initialization of the text area:

m_mfgInfo.setWildcard(m_mfgInfoBuf);
m_mfgInfo.setTypedText(touchgfx::TypedText(T_MFG_INFO));
m_mfgInfo.setXY(150, 150);
m_mfgInfo.resizeToCurrentText();
add(m_mfgInfo);

Update of the text area:

void MyView::SetData(MyData_t& data)
{
 
 Unicode::strncpy(m_mfgInfoBuf, data.mfgInfo->c_str(),
 static_cast<uint16_t>(data.mfgInfo.length()));
 
 m_mfgInfo.resizeToCurrentText();
 m_mfgInfo.invalidate();
 
}

Result:

0693W00000Bbp5KQAR.png 

I have verified that if I replace the characters that trigger the wildcard with "P", that the string is displayed without the wildcards.

I am at a loss as to how to explain this. Any help would be greatly appreciated.

This topic has been closed for replies.
Best answer by MM..1

In TouchGFX designer font window you need define char ranges for desired font used in textarea. Without this def your code know only characters used on strings entered as default in designer, all other is replaced by ?

2 replies

MM..1
MM..1Best answer
Super User
June 23, 2021

In TouchGFX designer font window you need define char ranges for desired font used in textarea. Without this def your code know only characters used on strings entered as default in designer, all other is replaced by ?

CPaye.1
CPaye.1Author
Associate III
June 23, 2021

MM - Good call! That was it. I was not using Designer for this view and I completely forgot about having to define the wildcard ranges and characters. I had a small range defined so that is probably why some characters were interpreted correctly.

Thanks for the help.