Re: [Lazarus] Unicode on Windows

2012-04-10 Thread Mattias Gaertner
On Tue, 10 Apr 2012 12:15:22 +0200 Hans-Peter Diettrich 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 type of 4 byt

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 l

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 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... S

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 (BasicMapping

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 8:17 PM, Hans-Peter Diettrich 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 (shoul

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 5:43 PM, Mattias Gaertner wrote: > On Mon, 9 Apr 2012 16:59:57 -0300 > Marcos Douglas wrote: > >>[...] >> > Length = size in bytes >> > UTF8Length = number of code points >> > >> > There is no generic function LengthInGlyphs, because this depends on the >> > font engine and

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 5:05 PM, Felipe Monteiro de Carvalho wrote: > > On Mon, Apr 9, 2012 at 4:50 PM, Marcos Douglas 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

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 Enc

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 Mattias Gaertner
On Mon, 9 Apr 2012 16:59:57 -0300 Marcos Douglas 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 will t

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Felipe Monteiro de Carvalho
On Mon, Apr 9, 2012 at 4:50 PM, Marcos Douglas 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: http://wiki.lazarus.freepascal.org/LC

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 3:39 PM, Mattias Gaertner wrote: > > On Mon, 09 Apr 2012 19:23:08 +0200 > Jürgen Hestermann wrote: > > > Marcos Douglas schrieb: > >  > Lenght function do not works with UTF8 correctly. > >  > procedure TForm1.Button1Click(Sender: TObject); > >  > begin > >  >   Edit1.Text

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Mattias Gaertner
On Mon, 09 Apr 2012 19:23:08 +0200 Jürgen Hestermann 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))); > > end; > >

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Mattias Gaertner
On Mon, 09 Apr 2012 19:18:15 +0200 Jürgen Hestermann 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 wh

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 2:18 PM, Jürgen Hestermann 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 part of code

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

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 func

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 glyp

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 12:17 PM, Mattias Gaertner wrote: > On Mon, 9 Apr 2012 11:50:37 -0300 > Marcos Douglas wrote: > >> On Mon, Apr 9, 2012 at 11:14 AM, Felipe Monteiro de Carvalho >> wrote: >> > >> > On Mon, Apr 9, 2012 at 2:37 PM, Marcos Douglas wrote: >> > > The result is 5 not 3, but you

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Mattias Gaertner
On Mon, 9 Apr 2012 11:50:37 -0300 Marcos Douglas wrote: > On Mon, Apr 9, 2012 at 11:14 AM, Felipe Monteiro de Carvalho > wrote: > > > > On Mon, Apr 9, 2012 at 2:37 PM, Marcos Douglas wrote: > > > The result is 5 not 3, but you did know this of course. > > > > If you study carefully UTF-8 and fo

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 11:18 AM, Marco van de Voort 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??'; >>   ShowMessage(IntToStr(Len

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 11:14 AM, Felipe Monteiro de Carvalho wrote: > > On Mon, Apr 9, 2012 at 2:37 PM, Marcos Douglas 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

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 k

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Felipe Monteiro de Carvalho
On Mon, Apr 9, 2012 at 2:37 PM, Marcos Douglas 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 Length returns the

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 9:19 AM, Felipe Monteiro de Carvalho wrote: > > On Mon, Apr 9, 2012 at 2:04 PM, Marcos Douglas 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

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Felipe Monteiro de Carvalho
On Mon, Apr 9, 2012 at 2:04 PM, Marcos Douglas 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 work automati

Re: [Lazarus] Unicode on Windows

2012-04-09 Thread Marcos Douglas
On Mon, Apr 9, 2012 at 12:30 AM, Mattias Gaertner wrote: > > On Sat, 7 Apr 2012 23:49:42 -0300 > Marcos Douglas 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

Re: [Lazarus] Unicode on Windows

2012-04-08 Thread Mattias Gaertner
On Sat, 7 Apr 2012 23:49:42 -0300 Marcos Douglas 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; > begin >

[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);