Author: Jonas Bilinkevicius How to determine if a Unicode string is Baltic or Russian Answer: 1 procedure TForm1.SetReadableText(const ws: WideString); 2 var 3 s: string; 4 pch: PChar; 5 i, CodePage, Charset: Integer; 6 begin 7 CodePage := 1252; 8 Charset := ANSI_CHARSET; 9 pch := PChar(PWideChar(ws)); 10 for i := 0 to length(ws) - 1 do 11 begin 12 if ord(pch[2 * i + 1]) = 1 then 13 begin 14 CodePage := 1257; 15 Charset := BALTIC_CHARSET; 16 break; 17 end; 18 if ord(pch[2 * i + 1]) = 4 then 19 begin 20 CodePage := 1251; 21 Charset := RUSSIAN_CHARSET; 22 break; 23 end; 24 end; 25 setlength(s, 2 * length(ws)); 26 setlength(s, WideCharToMultiByte(CodePage, 0, PWideChar(ws), length(ws), 27 PChar(s), length(s), nil, nil)); 28 Edit1.Font.Charset := Charset; 29 Edit1.Text := s; 30 end;