Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Determin if a Unicode string is Baltic or Russian Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
24-Aug-03
Category
Object Pascal-Strings
Language
Delphi 3.x
Views
184
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			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;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC