Sorry for going further on the subject. I have started an
introductory wiki-page that should be a kind of knowledge
base for those (if any) trying/thinking about
Unicode-enabling win32 interface:

http://wiki.lazarus.freepascal.org/index.php/LCL_Unicode_Support

Of course, currently there is not exactly much information there.

Here follow two concept procedures that just describe a
possible logic of what should happen at the boundary between
win32 widgetset and WinAPI. Could some core developer take a
look and comment, please. Those interested in Unicode are
also invited to comment, of course.

Regards,
Borut

var
 UseUnicode : Boolean;  //Global variable, so that application can initialise 
global behaviour

procedure FromWidgetToWinAPI(Text:String);
begin
  if UseUnicode then // implicit statement: Text is UTF-8 encoded
  begin
   if RunningOnUnicodeenabledPlatform
   then Call_Set_API_W(UTF8ToUTF16(Text))            //reencode to UTF-16 and 
call *W
   else Call_Set_API_A(UTF8ToActiveCodePage(Text));  //reencode to ISO-xxxx and 
call *A (possible information loss)
  end else           // implicit statement: Text is NOT UTF-8 encoded
  begin
   Call_Set_API_A(Text); // current case (not meaningful if text is UTF-8 
encoded)
  end;
end;

function FromWinAPIToWidget : String;
var W : WideString;
    S : String;
begin
  if UseUnicode then // implicit statement: Result should be UTF-8 encoded
  begin
    if RunningOnUnicodeenabledPlatform then
    begin
      W:=Call_Get_API_W;
      Result:=UTF16ToUTF8(W);            //reencode from UTF-16 to UTF-8
    end else
    begin
      S:=Call_Get_API_A;
      Result:=ActiveCodePageToUTF8(S);   //reencode from UTF-16 to ISO-xxxx 
(possible information loss)
    end;
  end else          // implicit statement: Result should NOT be UTF-8 encoded
  begin
   Result:=Call_Get_API_A; // current case (not meaningful if Result will later 
be treated as UTF-8 encoded)
  end;
end;






_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to