[icq-devel] ??? 16-bit Unicode Chars & Delphi ???



Alex Demchenko alex at ritlabs.com
Wed Jul 3 16:05:38 CEST 2002


Hello icq2000cc,

Wednesday, June 26, 2002, 9:44:31 PM, you wrote:

i> I got some trouble, when I started to work with ROSTER. // SNAC(13,X)
i> When I receiving a ROSTER, some NickNames are represented
i> as 16-bit Unicode chars (?) or as WideChar chars(?).
They are in UTF-8 format, converting to ASCII format below(Delphi).

i> Who can help me?
Me :)

i> --- cut snac(13,6) ---
i> 00 09 31 31 31 31 31 31 31 31 31  // UIN
i> 1E 8F                             // group-id
i> 38 9F                             // contact-id
i> 00 00 00 10                       // tlv(0)
i>       01 31 00 0C                 // tlv(0131)
i>             D09C D0B8 D0BB D0B5 D0BD D0B0 // NickName in Russian
i> --- cut snac(13,6) ---

function UTFToStr(Value: String): String;
var
  buffer: Pointer;
  BufLen: LongWord;
begin
  BufLen := Length(Value); Inc(BufLen, 4);
  GetMem(buffer, BufLen);
  FillChar(buffer^, BufLen, 0);
  MultiByteToWideChar(CP_UTF8, 0, @Value[1], BufLen - 4, buffer, BufLen);
  Result := WideCharToString(buffer);
  FreeMem(buffer, BufLen);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  S: String;
begin
  S := #$D0#$9C#$D0#$B8#$D0#$BB#$D0#$B5#$D0#$BD#$D0#$B0; //D09C D0B8 D0BB D0B5 D0BD D0B0 // NickName in Russian
  Memo1.Lines.Add(UTFToStr(S));
end;

-- 
Best regards,
 Alex                            mailto:alex at ritlabs.com




More information about the icq-devel mailing list