2019-05-22 01:22 AM
Hello,
i use snprintf function to print some UnicodeChar variable. But i have trouble to get special charcters printed (as é, è, ü...) by the mean of this function.
(even if i have declared in the typography wildcard Character column the special characters (éè) )
What is the right way to have these specials characters printed ?
Thanks
best regards
exemple :
touchgfx::Unicode::UnicodeChar start_txt_next_service_valueBuffer[START_TXT_NEXT_SERVICE_VALUE_SIZE];
Unicode::snprintf(start_txt_next_service_valueBuffer, START_TXT_NEXT_SERVICE_VALUE_SIZE, "%d %s", CAN_getNextServiceDays(), TypedText(T_START_NEXT_SERVICE_DAYS).getText());
2019-06-13 06:26 AM
Hi @Professional,
I don't remember if we touched on this in another post or if i missed this completely.
"special" characters are not that special, they're represented by unicodes like any other char. é: Unicode Character 'LATIN SMALL LETTER E WITH ACUTE' (U+00E9).
If the glyph is in your font then its possible to generate by the fontconverter. What are you seeing in your application? Did you get anywhere on your own since i took so long to answer?
/Martin
2019-06-13 06:40 AM
Hello
thanks for you reply. The call to
Unicode::snprintf(start_txt_next_service_valueBuffer, START_TXT_NEXT_SERVICE_VALUE_SIZE, "%s", TypedText(T_START_NEXT_SERVICE_DAYS).getText());
doesn't work (i have ? printed instead of é or è).
What should i do to be sure i have all the glyph (é à è ü...) in my font using sprintf function ?
thanks
best regards
2019-06-13 04:04 PM
Check your /generated/fonts folder for the particular typography you're using with that textarea. See if the unicode has been generated. If not, then you'll see the fallback char "?"
2019-06-14 12:49 AM
Hello,
thanks for your reply, so to be sure all special characters are generated, it is better to add them in wildcard charracters column of all fonts ?
best regards
2019-06-14 01:42 AM
Hi @Professional,
You can add an entire range if you want to be sure you've generated everything. The font converter does the following:
So, in your case, if you just want your static texts + a few extra glyphs, then you would just add a few extra wildcard characters as needed. No need to generate more than necessary, because it will take up flash memory.
/Martni
2019-06-14 02:13 AM
Hello,
thanks for your reply
but the Unicode::snprintf(start_txt_next_service_valueBuffer, START_TXT_NEXT_SERVICE_VALUE_SIZE, "%s", TypedText(T_START_SERVICE_LINE2_NUM14).getText());
doesn't work even with adding the characters in the fonts :
(i verified in the fonts used by the ressource T_START_SERVICE_LINE2_NUM14 that the characters are generated)
I should display "prévue" and "pr?vue" is printed.
I have them in the font file
// Unicode: [0x00D3, Oacute]
0x00, 0x00, 0x70, 0x02, 0x00, 0x00, 0x00, 0xA5, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
0xC4, 0xEE, 0x2B, 0x00, 0x40, 0x4E, 0x00, 0xE6, 0x01, 0xC0, 0x06, 0x00, 0xA0, 0x08, 0xF0, 0x01,
0x00, 0x50, 0x0C, 0xF2, 0x00, 0x00, 0x30, 0x0E, 0xF2, 0x00, 0x00, 0x30, 0x0E, 0xF0, 0x01, 0x00,
0x50, 0x0C, 0xC0, 0x06, 0x00, 0xA0, 0x08, 0x40, 0x3E, 0x00, 0xE6, 0x01, 0x00, 0xC4, 0xEE, 0x2B,
0x00,
// Unicode: [0x00E8, egrave]
0x00, 0xA7, 0x00, 0x00, 0x00, 0xA0, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x20, 0xDB, 0x5D, 0x00,
0xD0, 0x04, 0xD1, 0x02, 0xD3, 0x00, 0x80, 0x07, 0xF4, 0xCC, 0xDC, 0x08, 0xD3, 0x00, 0x00, 0x00,
0xD0, 0x04, 0xB0, 0x04, 0x20, 0xCB, 0x8D, 0x00,
// Unicode: [0x00E9, eacute]
0x00, 0x20, 0x1E, 0x00, 0x00, 0xA0, 0x03, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0xDB, 0x5D, 0x00,
0xD0, 0x04, 0xD1, 0x02, 0xD3, 0x00, 0x80, 0x07, 0xF4, 0xCC, 0xDC, 0x08, 0xD3, 0x00, 0x00, 0x00,
0xD0, 0x04, 0xB0, 0x04, 0x20, 0xCB, 0x8D, 0x00,
What can be the problem ?
best regards
2019-06-14 02:21 AM
Hi again,
Okay, so the glyph is actually being generated. Great. I think i'll have to come up with an example when i get a little time.
/Martin
2019-06-14 02:25 AM
Something to try on your own in the meantime - Does this make sense? Maybe it's an editor thing where it does not recognize the entered special symbol properly. Just explicitly name the unicodes and copy it to the buffer like this:
Unicode::UnicodeChar buf[] = { 0x00E9, 0 /*termination*/ };
Unicode::snprintf(wildcardBuffer, 2, "%s", buf);
/Martin
2019-06-14 04:53 AM
Hello,
no your code it doesn't work : also a ? printed
Here is the designer containt
in the ressource tab (prévue string contains é character that is printed with a ?:
and special characters are declared:
your code Unicode::snprintf(start_txt_next_service_valueBuffer, 2, "%s", buf); prints a "?"
my code Unicode::snprintf(start_txt_next_service_valueBuffer, START_TXT_NEXT_SERVICE_VALUE_SIZE, "%s", TypedText(T_START_SERVICE_LINE2_NUM14).getText());
prints "pr?vue"
start_txt_next_service_value.setVisible(true);
start_txt_next_service_value.invalidate();