NetTalk Central

Author Topic: Email subject wrong codepage problem after upgrading (NT10->NT14)  (Read 987 times)

qiqo

  • Newbie
  • *
  • Posts: 4
    • View Profile
Greetings,
I have a problem with subject field (and also organization and  filename (attachment)..).
in the previous version (NT 10) I filled the subject field with a string (codepage 1250) converted to utf8 (same as the messageText field), and everything was fine. 
After upgrading to NT14, sending emails created in the same way does not bring correct characters in the subject field (messageText is still OK).
Example, subject: "TEST ?đčć??ĐČĆ?" now I get as "TEST ??? ??? ?".
The problem is obviously in the MaybeEncodeString procedure (NetEmail.clw). Whatever I tried, after calling MaybeEncodeString codepage is wrong (western europe 1252, and not Central/Eastern Europe 1250)... It seems to me that setCodePage doesn't work as expected?!
Everything seems to be fine when I change line
str.ToUnicode(st:EncodeUtf8,self.codepage)
To
str.ToUnicode(st:EncodeUtf8,st:CP_WINDOWS_1250).

Regards, QiQo
« Last Edit: November 21, 2023, 06:21:38 AM by qiqo »

qiqo

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Email subject wrong codepage problem after upgrading (NT10->NT14)
« Reply #1 on: November 21, 2023, 10:22:06 PM »
I figure it out: setCodePage input parameter is charset, not codepage (strange, I don't know what is the reason for that?)... so setCodePage(st:CP_WINDOWS_1250) is wrong (and do nothing).. and setCodePage(CHARSET:EASTEUROPE) changed codePage...
MaybeEncodeString procedure still bothers me because I can't bypass the re-encoding (I have to change the code in a lot of places, delete my encoding to utf8 and add the code page change), while with the textMessageST field nothing changet, I still have to do that (?)
« Last Edit: November 21, 2023, 10:24:21 PM by qiqo »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11179
    • View Profile
Re: Email subject wrong codepage problem after upgrading (NT10->NT14)
« Reply #2 on: November 29, 2023, 10:10:39 PM »
>> setCodePage input parameter is charset, not codepage (strange, I don't know what is the reason for that?).

SetCodePage takes a charset, and sets the CodePage parameter based on that charset.
If you already know the code page (1250 etc) then you can just set the .codepage property to that codepage. As in

net.codepage = st:CP_WINDOWS_1253

>> MaybeEncodeString procedure still bothers me because I can't bypass the re-encoding

For 14.14 I have added a check on he encoding property. So if your subject text is already utf-8, then you can set
net.encoding = st:EncodeUtf8
and it will not convert it to utf-8. It will still EncodeWordEncode it, but that's necessary for the Subject line.