Решение проблемы с принятием сообщений в кодировке UTF-16 (без претензий на красоту и быстроту):
Модуль TICQClient.pas
...
procedure TICQClient.HSnac0407(Flap: TFlapHdr; Snac: TSnacHdr; Pkt: PRawPkt);
...
Msg := GetStr(Pkt, ULen);//The actual message text. There will be no ending NULL.
// Начало вставки
if CharsetNumber = 2 then Msg := UTF16ToStr(Msg)
else
// Конец вставки
if not ((CharsetNumber=0) or (CharsetNumber=3))
...
Модуль ICQWorks.pas
...
interface
...
function UTF16ToStr(Value: String): String;
...
implementation
...
{Convert string from UTF-16 format into ASCII}
function UTF16ToStr(Value: String): String;
var
x : string[1];
s : word;
i : word;
begin
for i := 1 to Length(Value) div 2 do begin
s := ord(Value[i*2-1])*256+ord(Value[i*2]);
x := WideCharToString(@s);
result := result + x;
end;
end;
...
__________________
{$R snt.res} <<<
Последний раз редактировалось sai_NT; 12.04.2008 в 14:48.
Причина: .
|