Re: [Lazarus] Unicode on Windows

2012-04-10 Thread Sven Barth
Am 10.04.2012 01:17, schrieb Hans-Peter Diettrich: Now every user has the choice to stay with a specific FPC/Lazarus version, that does not yet support the new string types, or to drop UTF-8 strings in favor of the new UTF-16 strings. Since most code has to deal with the Unicode BMP

Re: [Lazarus] Unicode on Windows

2012-04-10 Thread Sven Barth
Am 10.04.2012 03:50, schrieb Marcos Douglas: On Mon, Apr 9, 2012 at 8:17 PM, Hans-Peter Diettrich drdiettri...@aol.com wrote: Marcos Douglas schrieb: I still think about: DirectoryExists or DirectoryExistsUTF8 ForceDirectoriesUTF8 or ForceDirectories Pos or UTF8Pos etc Depends what part of

Re: [Lazarus] Unicode on Windows

2012-04-10 Thread Hans-Peter Diettrich
Sven Barth schrieb: You do know that WideChar and UnicodeChar are the same? Namely two byte characters. Hmm, you are right, but somewhere I saw it declared differently. Does there exist another char type of 4 bytes? DoDi -- ___ Lazarus mailing

Re: [Lazarus] Unicode on Windows

2012-04-10 Thread Mattias Gaertner
On Tue, 10 Apr 2012 12:15:22 +0200 Hans-Peter Diettrich drdiettri...@aol.com wrote: Sven Barth schrieb: You do know that WideChar and UnicodeChar are the same? Namely two byte characters. Hmm, you are right, but somewhere I saw it declared differently. Does there exist another char

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 12:30 AM, Mattias Gaertner nc-gaert...@netcologne.de wrote: On Sat, 7 Apr 2012 23:49:42 -0300 Marcos Douglas m...@delfire.net wrote: Hi, Using FPC 2.6.1 and Laz trunk on Windows, there is a better way to not to do such codes below? Examples 1- I'm on the

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Felipe Monteiro de Carvalho
On Mon, Apr 9, 2012 at 2:04 PM, Marcos Douglas m...@delfire.net wrote: Ops... you're right. I was confused because IncludeTrailingPathDelimiter is part of RTL and it not works with UTF8. The code uses Length and Result[l]... so, I thought this is would be problem. Some routines made for Ansi

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 9:19 AM, Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com wrote: On Mon, Apr 9, 2012 at 2:04 PM, Marcos Douglas m...@delfire.net wrote: Ops... you're right. I was confused because IncludeTrailingPathDelimiter is part of RTL and it not works with UTF8.

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Felipe Monteiro de Carvalho
On Mon, Apr 9, 2012 at 2:37 PM, Marcos Douglas m...@delfire.net wrote: The result is 5 not 3, but you did know this of course. If you study carefully UTF-8 and follow the code of the RTL routines you will find out that some routines work with UTF-8 without changes, regardless of the fact that

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marco van de Voort
On Mon, Apr 09, 2012 at 09:37:16AM -0300, Marcos Douglas wrote: Lenght function do not works with UTF8 correctly. procedure TForm1.Button1Click(Sender: TObject); begin Edit1.Text := '??b??'; ShowMessage(IntToStr(Length(Edit1.Text))); end; The result is 5 not 3, but you did know this

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 11:14 AM, Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com wrote: On Mon, Apr 9, 2012 at 2:37 PM, Marcos Douglas m...@delfire.net wrote: The result is 5 not 3, but you did know this of course. If you study carefully UTF-8 and follow the code of the RTL

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 11:18 AM, Marco van de Voort mar...@stack.nl wrote: On Mon, Apr 09, 2012 at 09:37:16AM -0300, Marcos Douglas wrote: Lenght function do not works with UTF8 correctly. procedure TForm1.Button1Click(Sender: TObject); begin   Edit1.Text := '??b??';  

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Mattias Gaertner
On Mon, 9 Apr 2012 11:50:37 -0300 Marcos Douglas m...@delfire.net wrote: On Mon, Apr 9, 2012 at 11:14 AM, Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com wrote: On Mon, Apr 9, 2012 at 2:37 PM, Marcos Douglas m...@delfire.net wrote: The result is 5 not 3, but you did know

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 12:17 PM, Mattias Gaertner nc-gaert...@netcologne.de wrote: On Mon, 9 Apr 2012 11:50:37 -0300 Marcos Douglas m...@delfire.net wrote: On Mon, Apr 9, 2012 at 11:14 AM, Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com wrote: On Mon, Apr 9, 2012 at 2:37 PM,

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marco van de Voort
On Mon, Apr 09, 2012 at 11:56:50AM -0300, Marcos Douglas wrote: The result is 5 not 3, but you did know this of course. Both are valid results. The first is needed when you copy the string (bytes to move) the second to display the string (since it will probably be around 3 glyphs (yes, I

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Jürgen Hestermann
Marcos Douglas schrieb: For the Lazarus sources yes, but not for RTL. I still think about: DirectoryExists or DirectoryExistsUTF8 ForceDirectoriesUTF8 or ForceDirectories Pos or UTF8Pos etc Depends what part of code you are... Yes, it's a real pain. I once used the Windows API function

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Jürgen Hestermann
Marcos Douglas schrieb: Lenght function do not works with UTF8 correctly. procedure TForm1.Button1Click(Sender: TObject); begin Edit1.Text := 'ábç'; ShowMessage(IntToStr(Length(Edit1.Text))); end; The result is 5 not 3, but you did know this of course. Yes. For Unicode encoding we

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 2:18 PM, Jürgen Hestermann juergen.hesterm...@gmx.de wrote: Marcos Douglas schrieb: For the Lazarus sources yes, but not for RTL. I still think about: DirectoryExists or DirectoryExistsUTF8 ForceDirectoriesUTF8 or ForceDirectories Pos or UTF8Pos etc Depends what

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Mattias Gaertner
On Mon, 09 Apr 2012 19:18:15 +0200 Jürgen Hestermann juergen.hesterm...@gmx.de wrote: Marcos Douglas schrieb: For the Lazarus sources yes, but not for RTL. I still think about: DirectoryExists or DirectoryExistsUTF8 ForceDirectoriesUTF8 or ForceDirectories Pos or UTF8Pos etc

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Mattias Gaertner
On Mon, 09 Apr 2012 19:23:08 +0200 Jürgen Hestermann juergen.hesterm...@gmx.de wrote: Marcos Douglas schrieb: Lenght function do not works with UTF8 correctly. procedure TForm1.Button1Click(Sender: TObject); begin Edit1.Text := 'ábç'; ShowMessage(IntToStr(Length(Edit1.Text)));

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 3:39 PM, Mattias Gaertner nc-gaert...@netcologne.de wrote: On Mon, 09 Apr 2012 19:23:08 +0200 Jürgen Hestermann juergen.hesterm...@gmx.de wrote: Marcos Douglas schrieb:   Lenght function do not works with UTF8 correctly.   procedure TForm1.Button1Click(Sender:

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Felipe Monteiro de Carvalho
On Mon, Apr 9, 2012 at 4:50 PM, Marcos Douglas m...@delfire.net wrote: Agree. But I did not wanted to check every single function if will work or not. That would be very dangerous. You could start a section in the wiki and help us document this. A section in this page:

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Mattias Gaertner
On Mon, 9 Apr 2012 16:59:57 -0300 Marcos Douglas m...@delfire.net wrote: [...] Length = size in bytes UTF8Length = number of code points There is no generic function LengthInGlyphs, because this depends on the font engine and some code points do not have a glyph. In the future, we

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Hans-Peter Diettrich
Mattias Gaertner schrieb: Yes. For Unicode encoding we would need new functions to distinguish between number of bytes and number of (visible) glyphs: LengthInBytes() LengthInGlyphs() It should be mentioned that Unicode allows for different encodings of composed/decomposed characters. E.g.

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Hans-Peter Diettrich
Marcos Douglas schrieb: I still think about: DirectoryExists or DirectoryExistsUTF8 ForceDirectoriesUTF8 or ForceDirectories Pos or UTF8Pos etc Depends what part of code you are... Such problems may (should) go away with the new Unicode- and AnsiString types, where AnsiString contains an

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 5:05 PM, Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com wrote: On Mon, Apr 9, 2012 at 4:50 PM, Marcos Douglas m...@delfire.net wrote: Agree. But I did not wanted to check every single function if will work or not. That would be very dangerous. You

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 5:43 PM, Mattias Gaertner nc-gaert...@netcologne.de wrote: On Mon, 9 Apr 2012 16:59:57 -0300 Marcos Douglas m...@delfire.net wrote: [...] Length = size in bytes UTF8Length = number of code points There is no generic function LengthInGlyphs, because this depends on

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 8:17 PM, Hans-Peter Diettrich drdiettri...@aol.com wrote: Marcos Douglas schrieb: I still think about: DirectoryExists or DirectoryExistsUTF8 ForceDirectoriesUTF8 or ForceDirectories Pos or UTF8Pos etc Depends what part of code you are... Such problems may

Re: [Lazarus] Unicode on Windows

2012-04-08 Thread Mattias Gaertner
On Sat, 7 Apr 2012 23:49:42 -0300 Marcos Douglas m...@delfire.net wrote: Hi, Using FPC 2.6.1 and Laz trunk on Windows, there is a better way to not to do such codes below? Examples 1- I'm on the LCL and I have an Edit (edtFileName): var lFileName: string; lStrings: TStrings;

[Lazarus] Unicode on Windows

2012-04-07 Thread Marcos Douglas
Hi, Using FPC 2.6.1 and Laz trunk on Windows, there is a better way to not to do such codes below? Examples 1- I'm on the LCL and I have an Edit (edtFileName): var lFileName: string; lStrings: TStrings; begin lStrings := TStrings.Create; try lFileName := Utf8ToSys(edtFileName.Text);