Hi,
I have an application that uses multiple language support, however I have noticed an issue with strings ending in certain chars are not correctly handled.
Display All
In the below example if i select a string I do not get the correct string returned, because some of the strings in strings_french are ending in 'é'.
infact returns "charge sélectionné/disponible:", rather than the correct "charge disponible".
I have found two workarounds:
1. remove any 'é' at the end of strings, eg. change "charge sélectionné" to "charge sélectionne"
2. change CRLF to either "\r\r\n" or "\r\n\n".
Have you come across this before?
Using STemWin V5.26.
Cheers
Spen
I have an application that uses multiple language support, however I have noticed an issue with strings ending in certain chars are not correctly handled.
C Source Code
- #define CRLF "\r\n"
- static const uint8_t strings_english[] = {
- "English"CRLF /* STR_LANGSTRING */
- "Searching"CRLF /* STR_SEARCHING */
- "Load Banks Found"CRLF /* STR_LOADBANK_FOUND */
- "Load Selected"CRLF /* STR_LOAD_SELECTED */
- "Load Available"CRLF /* STR_LOAD_AVAILABLE */
- "Load Selected/Available:"CRLF /* STR_LOAD_SELECTED_AVAILABLE */
- };
- static const uint8_t strings_french[] = {
- "Français"CRLF /* STR_LANGSTRING */
- "recherche"CRLF /* STR_SEARCHING */
- "Bancs de charge trouvés"CRLF /* STR_LOADBANK_FOUND */
- "charge sélectionné"CRLF /* STR_LOAD_SELECTED */
- "charge disponible"CRLF /* STR_LOAD_AVAILABLE */
- "charge sélectionné/disponible:"CRLF /* STR_LOAD_SELECTED_AVAILABLE */
- };
- static const struct STRING_LANG {
- const uint8_t *pData;
- const uint32_t NumBytes;
- } lang_string_array[MAX_LANGUAGE] = {
- {strings_english, ARRAY_SIZE(strings_english)},
- {strings_french, ARRAY_SIZE(strings_french)},
- };
- static int _GetData(void *pVoid, const uint8_t **ppData, unsigned NumBytes, uint32_t Off)
- {
- uint8_t *pDest = (uint8_t *)*ppData;
- const struct STRING_LANG *current_lang = pVoid;
- int bytes_read = NumBytes > current_lang->NumBytes ? current_lang->NumBytes : NumBytes;
- memcpy(pDest, current_lang->pData + Off, bytes_read);
- //LOG_DEBUG("load lang: %s %u", current_lang->pData, NumBytes);
- //LOG_DEBUG("load lang: %s %u", pDest, bytes_read);
- return bytes_read;
- }
- bool language_init(void)
- {
- DEBUG_ASSERT(MAX_LANGUAGE == ARRAY_SIZE(lang_string_array));
- GUI_LANG_SetMaxNumLang(MAX_LANGUAGE);
- for (unsigned i = 0; i < MAX_LANGUAGE; i++) {
- GUI_LANG_LoadTextEx(_GetData, (void *)&lang_string_array[i], i);
- }
- return true;
- }
In the below example if i select a string I do not get the correct string returned, because some of the strings in strings_french are ending in 'é'.
infact returns "charge sélectionné/disponible:", rather than the correct "charge disponible".
I have found two workarounds:
1. remove any 'é' at the end of strings, eg. change "charge sélectionné" to "charge sélectionne"
2. change CRLF to either "\r\r\n" or "\r\n\n".
Have you come across this before?
Using STemWin V5.26.
Cheers
Spen