[PATCH 1/2] Support translating UTF8 strings

Dirk Hohndel dirk at hohndel.org
Thu Nov 14 19:40:10 UTC 2013


But why would we ever even want to translate a tag? That made sense when we had fixed strings, but with random user supplied strings...
I'm confused.

/D

Maximilian Güntner <maximilian.guentner at gmail.com> wrote:

>There are no offending strings in the application itself. The problem
>only occurs
>when we try to translate custom tags (supplied by the user) that contain UTF-8
>characters or when we try to translate the translation of a tag (which
>contains UTF-8 characters).
>Implementation: struct divetag *taglist_add_tag(struct tag_entry
>*tag_list, const char *tag) in dive.c
>
>I hope that helps,
>
>Maximilian
>
>2013/11/14 Dirk Hohndel <dirk at hohndel.org>:
>> On Thu, 2013-11-14 at 19:47 +0100, Maximilian Güntner wrote:
>>> Interpreting UTF8 encoded strings using tr() instead of trUtf8()
>>> and encoding the string back to utf8 again leads to serious encoding
>>> errors.
>>
>> I didn't realize we had utf8 encoded strings in our sources...
>> Since some compilers frown upon that we used to always try and avoid
>> that. Can you point me to the offending strings?
>>
>> /D
>>
>>> Signed-off-by: Maximilian Güntner <maximilian.guentner at gmail.com>
>>> ---
>>>  gettextfromc.cpp | 2 +-
>>>  gettextfromc.h   | 2 +-
>>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/gettextfromc.cpp b/gettextfromc.cpp
>>> index c3b822f..fc11847 100644
>>> --- a/gettextfromc.cpp
>>> +++ b/gettextfromc.cpp
>>> @@ -6,7 +6,7 @@ const char *gettextFromC::trGettext(const char *text)
>>>  {
>>>       QByteArray &result = translationCache[QByteArray(text)];
>>>       if (result.isEmpty())
>>> -             result = tr(text).toUtf8();
>>> +             result = trUtf8(text).toUtf8();
>>>       return result.constData();
>>>  }
>>>
>>> diff --git a/gettextfromc.h b/gettextfromc.h
>>> index 6b5f7b1..c84d65f 100644
>>> --- a/gettextfromc.h
>>> +++ b/gettextfromc.h
>>> @@ -12,7 +12,7 @@ public:
>>>       static gettextFromC *instance();
>>>       const char *trGettext(const char *text);
>>>       void reset(void);
>>> -     QHash <QByteArray , QByteArray> translationCache;
>>> +     QHash <QByteArray, QByteArray> translationCache;
>>>  };
>>>
>>>  #endif // GETTEXTFROMC_H
>>
>>


More information about the subsurface mailing list