add support to unicode string for ktnef library #11

Unito
MicheleC ha unito 1 commit da bug/307 a master 5 anni fa
efferre 5 anni fa ha commentato
Collaboratori

I have enabled the ktnef library to decode unicode strings, it may solve the bug #307 (that was my case) but the original author of the bug should provide more data about his issue

I have enabled the ktnef library to decode unicode strings, it may solve the bug [#307](http://bugs.trinitydesktop.org/show_bug.cgi?id=307) (that was my case) but the original author of the bug should provide more data about his issue
SlavekB revisionato 5 anni fa
SlavekB 5 anni fa ha commentato
Proprietario

Using ascii() in almost all cases is not a good idea. Therefore, it is not good to add code that use ascii().
At least for the unicode string value, it seems better to use utf8().

Please, can you test the patch where you will use utf8() instead of ascii()?

Using `ascii()` in almost all cases is not a good idea. Therefore, it is not good to add code that use `ascii()`. At least for the unicode string value, it seems better to use `utf8()`. Please, can you test the patch where you will use `utf8()` instead of `ascii()`?
MicheleC revisionato 5 anni fa
MicheleC lascia un commento
Proprietario

toString().ascii()
is used in many places for debug here. Although the use of ascii() can give wrong result for strings with special characters, for the scope of the patch provided by Fabio I think it is acceptable to use ascii() here, in line with the rest of the code.

Converting from ascii() to utf8() should be the scope of a different PR and the conversion should be global.

toString().ascii() is used in many places for debug here. Although the use of ascii() can give wrong result for strings with special characters, for the scope of the patch provided by Fabio I think it is acceptable to use ascii() here, in line with the rest of the code. Converting from ascii() to utf8() should be the scope of a different PR and the conversion should be global.
MicheleC 5 anni fa ha commentato
Proprietario

sorry, comment above in "Review" was intended in reply to Slavek's comment in the code, but it seems gitea does not accept a comment in reply to another comment. still testing comment feature out 😉

sorry, comment above in "Review" was intended in reply to Slavek's comment in the code, but it seems gitea does not accept a comment in reply to another comment. still testing comment feature out :wink:
efferre 5 anni fa ha commentato
Autore
Collaboratori

@SlavekB: utf8() doesn't work because the strings are UCS2, which is common on Windows platforms. I have changed the code to leave TQString() managing the encoding and it seems to work as expected now.

@SlavekB: utf8() doesn't work because the strings are UCS2, which is common on Windows platforms. I have changed the code to leave TQString() managing the encoding and it seems to work as expected now.
MicheleC 5 anni fa ha commentato
Proprietario

Ciao Fabio,

hopefully I am not saying something totally wrong here.

utf8() alone should fail. The reason is in the way utf8() and TQCString work.

In short, utf8() returns a TQCString object. TQCString has a conversion "operator char * " method to convert to char . This works fine whenever utf8() result is passed to a const char * parameter. But when passed to a variable format string (%s), the conversion is not done automatically: the address of the TQCString is passed and interpreted as a const char, resulting in garbage printed to the screen.

Using printf(), I am 100% sure this happens (I had the same problem just yesterday 😉), using kdDebug() I am not 100% sure but it is likely to be the same.

Using utf8() requires something like this:

 mapi.value.toString().utf8().data()

PS: ascii() works fine because it returns a const char *

Ciao Fabio,<br> hopefully I am not saying something totally wrong here. utf8() alone should fail. The reason is in the way utf8() and TQCString work.<br> In short, utf8() returns a TQCString object. TQCString has a conversion "operator char * " method to convert to char *. This works fine whenever utf8() result is passed to a const char * parameter. But when passed to a variable format string (%s), the conversion is not done automatically: the address of the TQCString is passed and interpreted as a const char*, resulting in garbage printed to the screen. Using printf(), I am 100% sure this happens (I had the same problem just yesterday :wink:), using kdDebug() I am not 100% sure but it is likely to be the same. Using utf8() requires something like this: ``` mapi.value.toString().utf8().data() ``` PS: ascii() works fine because it returns a const char *
SlavekB hanno approvato queste modifiche 5 anni fa
SlavekB lascia un commento
Proprietario

Using kdDebug() as a stream looks very good. I have no objections. Thank you for your good contribution.

Using kdDebug() as a stream looks very good. I have no objections. Thank you for your good contribution.
efferre 5 anni fa ha commentato
Autore
Collaboratori

First of all I am using the file unicode-mapi-attr-name.tnef as usecase

The raw data is ucs2 so utf8 cannot work (I guess), please have a look to the new commit that should fix the debugging statement (at least on my system, I am not sure which is the default coding for TQString, otherwise it should be set in advance).

The above referenced TNEF file has unicode chars even in strings advertised as not unicode (so probably it's buggy). You can see in the GUI with Action -> Message Properties looking at the subject property.

I don't know anything about MAPI details (and I am not interested to know more :-) ), but it seems that the message subject is repeated twice in the file, the first time as "stand-alone" property (0x8004) and the second one in the MAPI properties (tag 0x0037). The first time is treated as regular string, the second as unicode.

First of all I am using the file [unicode-mapi-attr-name.tnef](https://github.com/verdammelt/tnef/blob/master/tests/files/datafiles/unicode-mapi-attr-name.tnef) as usecase The raw data is ucs2 so utf8 cannot work (I guess), please have a look to the new commit that should fix the debugging statement (at least on my system, I am not sure which is the default coding for TQString, otherwise it should be set in advance). The above referenced TNEF file has unicode chars even in strings advertised as not unicode (so probably it's buggy). You can see in the GUI with Action -> Message Properties looking at the subject property. I don't know anything about MAPI details (and I am not interested to know more :-) ), but it seems that the message subject is repeated twice in the file, the first time as "stand-alone" property (0x8004) and the second one in the MAPI properties (tag 0x0037). The first time is treated as regular string, the second as unicode.
MicheleC chiusa questa pull request 5 anni fa
MicheleC branch bug/307 eliminato 5 anni fa
MicheleC 5 anni fa ha commentato
Proprietario

Thanks Fabio, looks good. Merged and closed.

Keep up the good work 😉

Thanks Fabio, looks good. Merged and closed. Keep up the good work :wink:
MicheleC aggiunta alle pietre miliari R14.0.6 release 5 anni fa
La pull request è stata unita come 1340cc3235.
Effettua l'accesso per partecipare alla conversazione.
Nessun revisore
Nessuna milestone
Nessuna assegnatario
3 Partecipanti
Notifiche
Data di scadenza

Nessuna data di scadenza impostata.

Dipendenze

Nessuna dipendenza impostata.

Riferimento: TDE/tdepim#11
Caricamento…
Non ci sono ancora contenuti.