cancel
Showing results for 
Search instead for 
Did you mean: 

"Tildes" don't appear in wildcard texts.

Iñaki_Bidasoro
Associate III

Hi!

So I am doing a program that supports spanish as language, and in spanish we use the "tilde" which is just used sometimes to mark the accent of a word it looks like this: "Actualización", and when I put it in a wildcard it just shows the fallback character, even though I have put the ´áéíóú as wildcard characters.

1 ACCEPTED SOLUTION

Accepted Solutions
Iñaki_Bidasoro
Associate III

Okay so the solution for me was the following,

I created the following function in my utils static class so that i can use it: 

void Utils::Set_Text(const std::string &text, Unicode::UnicodeChar *buffer, size_t bufferSize)
{
  Unicode::fromUTF8((const uint8_t *)text.c_str(), buffer, bufferSize);
  Unicode::snprintf(buffer, bufferSize, "%s", buffer);
}

 Now we just use Set_Text() as any other strncpy or snprintf and every (at least in spanish) special char will appear.

Have a nice day.

View solution in original post

5 REPLIES 5
GaetanGodart
ST Employee

Hello @Iñaki_Bidasoro ,

 

I also struggled with it at first but I found a solution.
In most ascii table I found online, ñ was 164, but on wikipedia, it is 241 : List_of_Unicode_characters#Latin_script 
I just had to do :

 

char s[10] = {' '};
s[0] = char(241);
Unicode::snprintf(textArea1Buffer, 10, s);
textArea1.invalidate();

 

 

It is weird however that this 

 

Unicode::snprintf(textArea1Buffer, 10, 'ñ");
textArea1.invalidate();

 

 did not work.

 

You can also check this discussion : stm32cubeide-can-t-convert-touchgfx-wildcard-characters/td-p/183410 

 

Tell me if that solution is enough for you.

 

Hope this helps.
If this comment solves your problem, I invite you to select it as "best answer".

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

It is true that this does work

 

 

char s[10] = {' '};
s[0] = char(241);
Unicode::snprintf(textArea1Buffer, 10, s);
textArea1.invalidate();

 

 

But what i want is to pass a string that contains any char used in the spanish keyboard and know that it will work, as we don't know what we maybe displaying in the future, I don´t know if I explain myself.

And in that solution I need to know what char is the one that we need to snpritf as char(whatever) and know it's postition right?

Also, if I add a e.g. the text Actualización to the touchgfx text database using the Designer it does work. So there must be a way.

"But what i want is to pass a string that contains any char used in the spanish keyboard and know that it will work, as we don't know what we maybe displaying in the future, I don´t know if I explain myself."

Yes, I understand. You want it to work for every character, at every position and for every textArea.

 

"And in that solution I need to know what char is the one that we need to snpritf as char(whatever) and know it's position right?"

You could simply us "replace" to replace all instances of 'ñ' by char 241 as such :

std::replace(s.begin(), s.end(), 'ñ', char(241));

But you would have to add that line before every instances where you want to update a wildcard that could contain a Spanish character.
Also, you would have to do that for all Spanish specific character (Ñ, ó, etc).

 

"Also, if I add a e.g. the text Actualización to the touchgfx text database using the Designer it does work. So there must be a way."

So you add it a text and then, during runtime use it into a wildcard?
I assume it should be possible, but I still don't understand why we have this behavior in the first place so it is hard to fix.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)
Iñaki_Bidasoro
Associate III

Okay so the solution for me was the following,

I created the following function in my utils static class so that i can use it: 

void Utils::Set_Text(const std::string &text, Unicode::UnicodeChar *buffer, size_t bufferSize)
{
  Unicode::fromUTF8((const uint8_t *)text.c_str(), buffer, bufferSize);
  Unicode::snprintf(buffer, bufferSize, "%s", buffer);
}

 Now we just use Set_Text() as any other strncpy or snprintf and every (at least in spanish) special char will appear.

Have a nice day.

GaetanGodart
ST Employee

I am glad you found a solution!

Gaetan Godart
Software engineer at ST (TouchGFX)