[Lazarus] TProcess, UTF8, Windows

Sven Barth pascaldragon at googlemail.com
Sat Apr 14 11:36:59 CEST 2012


On 14.04.2012 07:20, Martin Schreiber wrote:
> On Friday 13 April 2012 20:32:23 Marcos Douglas wrote:
>> On Fri, Apr 13, 2012 at 2:59 PM, Martin Schreiber<mse00000 at gmail.com>
> wrote:
>>> On Friday 13 April 2012 18:51:42 Michael Van Canneyt wrote:
>>>> Also:
>>>> Lazarus happened to choose UTF-8 as the encoding of their LCL.
>>>> By contrast, MSEGui chose UTF-16 as it's encoding.
>>>
>>> In order to differentiate from other string types and encodings MSEgui
>>> uses "msestring" in properties, variables and parameters. msestring is
>>> defined as
>>> "
>>> type
>>>   msestring = UnicodeString;
>>> "
>>
>> But even so, we still can pass AnsiString<UTF8String, string,
>> whatever>  to a function:
>>
>> type
>>    MyString = UnicodeString;
>>
>> procedure Foo(const s: MyString);
>> begin
>>    ShowMessage(s);
>> end;
>>
>> procedure TForm1.Button1Click(Sender: TObject);
>> var
>>    s: AnsiString;
>> begin
>>    s := 'hi';
>>    Foo(s);
>> end;
>>
> Yes. And if "s" is not in utf-8 but in current system encoding it even will be
> translated correctly in FPC 2.6.0. ;-)

In that case it will also be translated correctly in 2.7.1. It will also 
be translated correctly if the AnsiString is defined as 
"AnsiString(CP_UTF8)" and has an UTF-8 encoded string in it.

Regards,
Sven





More information about the Lazarus mailing list