Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-10

cwstring in arm-linux

93 messages · 16 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Henry Vermaak

Hi list

In revision 31913, Felipe did this:

r31913 | sekelsenmat | 2011-08-08 12:23:08 +0100 (Mon, 08 Aug 2011) | 1 line

Fixes linking LCL-Android by disabling all links to libc in arm-linux

--- lcl/include/lcl_defines.inc (revision 31912)
+++ lcl/include/lcl_defines.inc (revision 31913)
@@ -1,2 +1,8 @@

  // Add defines here. This file should be included in all LCL units headers

-{$define UseCLDefault}
\ No newline at end of file
+{$define UseCLDefault}
+
+// For Android and other ARM-devices, otherwise the LCL will dependent on libc
+{$IFDEF ARM}{$IFDEF UNIX}
+ {$DEFINE DisableCWString}
+ {$DEFINE DisableIconv}
+{$ENDIF}{$ENDIF}

Could someone change this ifdef to ANDROID, or something other than ARM?

Henry

Reply by email

Felipe Monteiro de Carvalho
to Henry Vermaak
Henry Vermaak wrote
Could someone change this ifdef to ANDROID, or something other than ARM?

There is no such define in FPC, so either way is problematic.

I'll check if I can finish paswstring instead.

Felipe Monteiro de Carvalho

Reply by email

Henry Vermaak
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
On Mon, Oct 3, 2011 at 2:18 PM, Henry Vermaak wrote: > Could someone change this ifdef to ANDROID, or something other than ARM? There is no such define in FPC, so either way is problematic.

Yes, I know, but you can define ANDROID when you build lazarus from the command line. All my arm-linux systems have libc. I run a normal linux distro on my arm netbook, so the only alternative for me would be to patch that file.

Henry

Reply by email

zeljko
to Felipe Monteiro de Carvalho: Ok, I changed the define in rev 32655. But you should note that when paswstring gets…
Felipe Monteiro de Carvalho wrote
Ok, I changed the define in rev 32655. But you should note that when paswstring gets finished it will phase out cwstrings.

Only if it's 1/1 with cwstrings please :)

zeljko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111003/5bcdfe4d/attachment.html>

Reply by email

Felipe Monteiro de Carvalho
to Marco van de Voort
Marco van de Voort wrote
Not that I know. And btw, I also use arm-linux without android, so please keep that target intact and aligned with normal linux ports.

What is the difference between using cwstring and paswstring? Any reason for not wanting to use paswstring?

They should be 100% equal, except that one does not require any external libraries. If you can test and check if there are any differences of course would be excelent =)

Felipe Monteiro de Carvalho

Reply by email

Martin Schreiber
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
On Wed, Oct 19, 2011 at 12:06 PM, Marco van de Voort
Show quoted text 6 lines
> Not that I know. And btw, I also use arm-linux without android, so please > keep that target intact and aligned with normal linux ports. What is the difference between using cwstring and paswstring? Any reason for not wanting to use paswstring?

Where is paswstring?

Martin

Reply by email

Hans-Peter Diettrich
to Marco van de Voort: Not that I know. And btw, I also use arm-linux without android, so please keep that…
Show quoted text 8 lines
On Mon, Oct 03, 2011 at 04:31:20PM +0200, Felipe Monteiro de Carvalho wrote: > Ok, I changed the define in rev 32655. > > But you should note that when paswstring gets finished it will phase > out cwstrings. Not that I know. And btw, I also use arm-linux without android, so please keep that target intact and aligned with normal linux ports.

After some discussions in Embarcadero groups I would like to learn more about the FPC implementation and goals of the new (Unicode...) strings. Where should I have a look?

In detail it turned out that Delphi only supports CP_ACP strings for Ansi codepages, not including UTF-8. Strings with other encodings may be converted properly (not yet), but otherwise should not be used with standard stringhandling procedures. Will this be changed in the FPC RTL, so that at least UTF8Strings are also supported properly?

DoDi

Reply by email

Sven Barth
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote 20 lines
Marco van de Voort schrieb: > On Mon, Oct 03, 2011 at 04:31:20PM +0200, Felipe Monteiro de Carvalho > wrote: >> Ok, I changed the define in rev 32655. >> >> But you should note that when paswstring gets finished it will phase >> out cwstrings. > > Not that I know. And btw, I also use arm-linux without android, so please > keep that target intact and aligned with normal linux ports. After some discussions in Embarcadero groups I would like to learn more about the FPC implementation and goals of the new (Unicode...) strings. Where should I have a look? In detail it turned out that Delphi only supports CP_ACP strings for Ansi codepages, not including UTF-8. Strings with other encodings may be converted properly (not yet), but otherwise should not be used with standard stringhandling procedures. Will this be changed in the FPC RTL, so that at least UTF8Strings are also supported properly?

Uhm... isn't this better suited in fpc-devel?

Regards,
Sven

Reply by email

Martin Schreiber
to Felipe Monteiro de Carvalho: http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/components/lazutils/paswstring.pas?view…
Felipe Monteiro de Carvalho wrote
On Wed, Oct 19, 2011 at 1:24 PM, Martin Schreiber
Show quoted text 8 lines
> Where is paswstring? http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/components/lazutils/pasw string.pas?view=markup&root=lazarus It uses lazutf8 (which includes most importantly UTF16ToUTF8 and viceversa and utf8LowerCase and utf8UpperCase) and lconvencoding (which includes encoding tables) which are in the same folder.

Some possibly problematic points:
Does it use locale specific collation in PasUnicodeCompareStr and PasUnicodeCompareText?
Is the performance of UTF8LowerCase and UTF8UpperCase OK? Do UTF8LowerCase and UTF8UpperCase cover all upper/lowercase Unicode (possibly accented) characters? Does it handle decomposed characters (cwstring doesn't)?

Martin

Reply by email

Marco van de Voort
to Felipe Monteiro de Carvalho: What is the difference between using cwstring and paswstring? Any reason for not wanting…
Felipe Monteiro de Carvalho wrote 6 lines
On Wed, Oct 19, 2011 at 12:06 PM, Marco van de Voort wrote: > Not that I know. And btw, I also use arm-linux without android, so please > keep that target intact and aligned with normal linux ports. What is the difference between using cwstring and paswstring? Any reason for not wanting to use paswstring?

Simply integrating with the OS, and avoid inclusion of tables when not necessary.

Moreover you are stating something as a fact here that was not discussed at all.

They should be 100% equal, except that one does not require any external libraries. If you can test and check if there are any differences of course would be excelent =)

I haven't been testing it, and don't plan to. I'm not interested in it, and am not interested in growing the binaries unnecessarily.

I have no problem with having a second option for the people that do want it, but that is something entirely different from what you were saying.

Cwstring is staying on all normal targets as far as I know.

Reply by email

Felipe Monteiro de Carvalho
to Marco van de Voort
Marco van de Voort wrote
Moreover you are stating something as a fact here that was not discussed at all.

I am confused by your statements, the discussion here is about the usage of cwstring in the LCL, then I said that I want to replace cwstring with paswstring in the LCL (after making sure it is completely equivalent).

Are you also discussing about the usage of cwstring in the LCL? Your comments make me think that you are assuming I am talking about the RTL or something like that.

Felipe Monteiro de Carvalho

Reply by email

Martin Schreiber
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 12 lines
On Wed, Oct 19, 2011 at 6:47 PM, Marco van de Voort wrote: > Moreover you are stating something as a fact here that was not discussed > at all. I am confused by your statements, the discussion here is about the usage of cwstring in the LCL, then I said that I want to replace cwstring with paswstring in the LCL (after making sure it is completely equivalent). Are you also discussing about the usage of cwstring in the LCL? Your comments make me think that you are assuming I am talking about the RTL or something like that.

Ah, sorry, I read it wrong too...

Martin

Reply by email

Marco van de Voort
to Felipe Monteiro de Carvalho: I am confused by your statements, the discussion here is about the usage of cwstring in…
Felipe Monteiro de Carvalho wrote 8 lines
I am confused by your statements, the discussion here is about the usage of cwstring in the LCL, then I said that I want to replace cwstring with paswstring in the LCL (after making sure it is completely equivalent). Are you also discussing about the usage of cwstring in the LCL? Your comments make me think that you are assuming I am talking about the RTL or something like that.

No, sorry. Though I still think that is not a good thing either.

Reply by email

Vincent Snijders
to Marco van de Voort

2011/10/19 Marco van de Voort :

Show quoted text 11 lines
On Wed, Oct 19, 2011 at 06:59:06PM +0200, Felipe Monteiro de Carvalho wrote: > I am confused by your statements, the discussion here is about the > usage of cwstring in the LCL, then I said that I want to replace > cwstring with paswstring in the LCL (after making sure it is > completely equivalent). > > Are you also discussing about the usage of cwstring in the LCL? Your > comments make me think that you are assuming I am talking about the > RTL or something like that. No, sorry. Though I still think that is not a good thing either.

I guess Felipe gave up waiting on a Unicode RTL for the time being and goes for a full UTF8 pseudo RTL in LazUtils.

Vincent

Reply by email

Felipe Monteiro de Carvalho
to Martin Schreiber: Some possibly problematic points: Does it use locale specific collation in…
Martin Schreiber wrote
Does it use locale specific collation in PasUnicodeCompareStr and PasUnicodeCompareText?

Good point, no, not yet. But this affects only turkish, azeri and lithuanian AFAIK

Adding turkish and azeri is trivial, because UTF8LowerCase supports them, but I did not understand yet the rules for Lithuanian, they are quite convoluted, depend on nearby chars and stuff like that.

Is the performance of UTF8LowerCase and UTF8UpperCase OK?

UTF8LowerCase was heavily optimized. UTF8UpperCase still needs to be more optimized.

6 million UTF8LowerCase operations in the string "?????????????????" takes 2,6 seconds in my computer. It outperforms iconv by a factor of 2,5x aprox:

UTF8LowerCase-- Performance test took: 804 ms 1896 ms 2318 ms 3460 ms 2647 ms 1847 ms 2526 ms 2496 ms 1830 ms 1975 ms
CWString SysUtils.UnicodeLowerCase-- Performance test took: 2456 ms 2461 ms 6594 ms 6170 ms 5347 ms 6939 ms 4398 ms 4429 ms 2285 ms 2411 ms

For this strings:

      if j = 0 then Str := UTF8LowerCase('abcdefghijklmnopqrstuwvxyz');
      if j = 1 then Str := UTF8LowerCase('ABCDEFGHIJKLMNOPQRSTUWVXYZ');
      if j = 2 then Str := UTF8LowerCase('a?bc?de?fghijkl?mn?o?prs?tuwyz??');
      if j = 3 then Str := UTF8LowerCase('A?BC?DE?FGHIJKL?MN?O?PRS?TUWYZ??');
      if j = 4 then Str := UTF8LowerCase('?????????????????');
      if j = 5 then Str := UTF8LowerCase('????????????????');
      if j = 6 then Str :=
UTF8LowerCase('AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuWvVwXxYyZz');
      if j = 7 then Str :=
UTF8LowerCase('AAaaBBbbCCccDDddEEeeFFffGGggHHhhIIiiJJjjKKkkLLllMMmm');
      if j = 8 then Str := UTF8LowerCase('abcDefgHijkLmnoPqrsTuwvXyz');
      if j = 9 then Str := UTF8LowerCase('ABCdEFGhIJKlMNOpQRStUWVxYZ');
Do ?UTF8LowerCase and UTF8UpperCase cover all upper/lowercase Unicode (possibly accented) characters?

UTF8LowerCase currently covers all characters in the latest Unicode spec AFAIK. Of course I might have forgotten something, but I have tests for chars from 0000 to 0580 and more tests for other clusters.

UTF8UpperCase is currently implemented from 0000 to 0450, but I will add the rest.

Does it handle decomposed characters (cwstring doesn't)?

I think that decomposed characters should work naturally. See, for example, if we have: [0]=~ (tilde accent, but the special version for composition) [1]=A which forms "?" and then we pass lowercase into it, we would get [0] without change and [1]=a which forms "?". Or am I wrong?

If you are talking about handling for CompareText, then the answer would be that AFAIK it would be too inneficient to handle that in CompareText ... so we would need another routine for that NormalizedCompareText or something like that, which executes normalization, then lowercase and finally the comparison.

Felipe Monteiro de Carvalho

Reply by email

Felipe Monteiro de Carvalho
to Vincent Snijders: 2011/10/19 Marco van de Voort : I guess Felipe gave up waiting on a Unicode RTL for the…
Vincent Snijders wrote
I guess Felipe gave up waiting on a Unicode RTL for the time being and goes for a full UTF8 pseudo RTL in LazUtils.

Well, after a lot of discussion I got convinced that Lazarus should give a try at the UTF-8 mode of the RTL when this appears, and this might be very useful for our usage of TStringList, TComponent, TStream, etc. I think this solution has major problems, but it was claimed that my proposed solutions have much worse problems, so in the end I concluded that we should try the UTF-8 mode of the RTL when it appears.

But this does not mean that LazUtils would not be useful then. My proposals to add UTF-8 routines to the RTL and even FCL were rejected, so we UTF-8 users would need to be stuck with only whatever routines Embarcadero invents. That's not nearly good enough and not nearly fast enough. UTF8LowerCase is very superior to the existing RTL LowerCase. To start with, the RTL in existing release doesn't even have a UTF8String LowerCase (no idea about 2.7). Also, UTF8LowerCase has a second parameter to specify the language, so we can test and support Turkish without having to change our locale to turkish, and it outperforms SysUtils.UnicodeLowerCase by 250% aprox in my Mac, and it has zero external dependencies while depending on zero initialization code, zero global variables and having 1k lines of code (half of them comments), which is not that much. As you can see it vastly outperforms even what the UTF-8 mode of the RTL would offer for this.

Just like UTF8LowerCase, other things provided by LazUtils will also be useful options for Lazarus and other libraries/applications, regardless of FPC offering something similar. And then I think that everyone will be happy. People that want Delphi compatibility (excluding string and PChar, since they will not match in the RTL mode used by Lazarus) will be happy, they can use RTL routines and get compatibility. Lazarus will still be using string and TStringList, TComponent, etc.

Felipe Monteiro de Carvalho

Reply by email

Michael Van Canneyt
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 14 lines
On 10/19/11, Vincent Snijders wrote: > I guess Felipe gave up waiting on a Unicode RTL for the time being and > goes for a full UTF8 pseudo RTL in LazUtils. Well, after a lot of discussion I got convinced that Lazarus should give a try at the UTF-8 mode of the RTL when this appears, and this might be very useful for our usage of TStringList, TComponent, TStream, etc. I think this solution has major problems, but it was claimed that my proposed solutions have much worse problems, so in the end I concluded that we should try the UTF-8 mode of the RTL when it appears. But this does not mean that LazUtils would not be useful then. My proposals to add UTF-8 routines to the RTL and even FCL were rejected,

Correction: Your proposals were not rejected.

No decision as to which character sets will be used in the basic RTL has been taken. Any action you take now is therefor premature.

So it was suggested you would wait till things settle down till and the final shape of things are more clear.

This really is not the same as 'rejected'.

Michael.

Reply by email

Vincent Snijders
to Michael Van Canneyt

2011/10/19 Michael Van Canneyt :

Show quoted text 9 lines
On Wed, 19 Oct 2011, Felipe Monteiro de Carvalho wrote: > On 10/19/11, Vincent Snijders wrote: >> >> I guess Felipe gave up waiting on a Unicode RTL for the time being and >> goes for a full UTF8 pseudo RTL in LazUtils. >
Show quoted text 5 lines
> > But this does not mean that LazUtils would not be useful then. My > proposals to add UTF-8 routines to the RTL and even FCL were rejected, Correction: Your proposals were not rejected.

Thanks for the clarification.

Show quoted text 6 lines
No decision as to which character sets will be used in the basic RTL has been taken. Any action you take now is therefor premature. So it was suggested you would wait till things settle down till and the final shape of things are more clear.

That is why I said: "gave up waiting"

This really is not the same as 'rejected'.

Vincent

Reply by email

Žilvinas Ledas
to Felipe Monteiro de Carvalho: Good point, no, not yet. But this affects only turkish, azeri and lithuanian AFAIK Adding…

Hello,

Felipe Monteiro de Carvalho wrote 9 lines
On Wed, Oct 19, 2011 at 6:33 PM, Martin Schreiber wrote: > Does it use locale specific collation in PasUnicodeCompareStr and > PasUnicodeCompareText? Good point, no, not yet. But this affects only turkish, azeri and lithuanian AFAIK Adding turkish and azeri is trivial, because UTF8LowerCase supports them, but I did not understand yet the rules for Lithuanian, they are quite convoluted, depend on nearby chars and stuff like that.

I am native Lithuanian so I think can help at least providing info, but I must understand what is the problem first.
Do I understand correctly, that "collation" means "sorting order"? In that case Lithuanian does not depend on near by characters. There are 32 letters and they follow this order:
Aa < ?? < Bb < Cc < ?? < Dd < Ee < ?? < ?? < Ff < Gg < Hh < Ii < ?? < Yy < Jj < Kk < Ll < Mm < Nn < Oo < Pp < Rr < Ss < ?? < Tt < Uu < ?? < ?? < Vv < Zz < ??

And there are some accented characters which are used only in linguistic texts (for example, dictionaries). (All list is here: http://developer.mimer.com/charts/lithuanian.htm)

The funny thing is that in dictionaries when "sorting" words, "Aa" and "??" (also: "Ee" and "??" and "??"; "Ii" and "??" and "Yy"; "Uu" and "??" and "??") are treated as the "same letter".
BUT, for example words "?ien?" "sien?" "sien?" - all three are different words (no accents in these characters).
BUT I believe that accented characters should be treated as the same letter: "?ie?n?" = "?ien?"; "siena" = "si?ena", because it is the same word (accents do not change word meaning and are totally not required to be provided by the text writer).

I don't know if I managed to explain anything, but if you'll need some help with Lithuanian language - feel free to contact me.

Regards,
?ilvinas Ledas

Reply by email

Felipe Monteiro de Carvalho
to Žilvinas Ledas

Hello,

2011/10/19 ?ilvinas Ledas :

I am native Lithuanian so I think can help at least providing info, but I must understand what is the problem first.

I am mostly interested in LowerCase / UpperCase. Could you explain how it works in Lithuanian and provide test cases for it?

Test cases should be in this format:

  AssertStringOperationUTF8LowerCase('Unicode 0460 UTF8LowerCase', '',
'????????????????', '????????????????');

Even better if they are in patches to the file
lazarus/tests/lazutils/testunicode.pas

First param is the label, the second the locale (in this case maybe something like 'lt', what is the ISO identifier for lituanian? Then UpperCase and then LowerCase.

And try to make some tricky tests, to defeat partial implementations. 3 tests for lowercase and 3 for uppercase should be enough

Felipe Monteiro de Carvalho

Reply by email

Martin Schreiber
to Vincent Snijders: 2011/10/19 Michael Van Canneyt : Thanks for the clarification. That is why I said: "gave…
Vincent Snijders wrote 21 lines
2011/10/19 Michael Van Canneyt : > On Wed, 19 Oct 2011, Felipe Monteiro de Carvalho wrote: >> On 10/19/11, Vincent Snijders wrote: >>> I guess Felipe gave up waiting on a Unicode RTL for the time being and >>> goes for a full UTF8 pseudo RTL in LazUtils. >> >> But this does not mean that LazUtils would not be useful then. My >> proposals to add UTF-8 routines to the RTL and even FCL were rejected, > > Correction: Your proposals were not rejected. Thanks for the clarification. > No decision as to which character sets will be used in the basic RTL has > been taken. Any action you take now is therefor premature. > > So it was suggested you would wait till things settle down till and the > final shape of things are more clear. That is why I said: "gave up waiting"

I think it would have been better if Lazarus had made an RTL optimized for Lazarus long time ago. Now the FPC team destroyed a stable product in favor of Delphi string compatibility. The introduction of multi-encoding strings is not a really good idea IMHO but more a marketing gag.
It seems that the Delphi architects are not absolutely happy with it either. Allan Bauer in:
"
https://forums.codegear.com/message.jspa?messageID=400258#400258 "
"
We have way, way too many different string types. It's confusing. "
There are more interesting statements in that thread, ex.: "
https://forums.codegear.com/message.jspa?messageID=399964#399964 "
It is even possible that Delphi strings change again...

Martin

Reply by email

Michael Schnell
to Martin Schreiber
Martin Schreiber wrote
Now the FPC team destroyed a stable product in favor of Delphi string compatibility.

I don't consider the current state of Lazarus "stable", as IMHO the "UTF8 in type ANSIString" paradigm (seemingly forced by the underlying FPC version) is too "special" to stay.

As I don't have a Delphi > 2009, I have no idea if the "new" Delphi way to handle Unicode is desirable or even this is not meant as a criticism whatsoever.

-Michael

Reply by email

Martin Schreiber
to Michael Schnell
you wrote 5 lines
On 10/20/2011 09:18 AM, Martin Schreiber wrote: > Now the FPC team destroyed a stable product in favor of > Delphi string compatibility. I don't consider the current state of Lazarus "stable",

I don't refer to Lazarus but to Free Pascal compiler, RTL and FCL.

Martin

Reply by email

Michael Schnell
Martin Schreiber wrote
I don't refer to Lazarus but to Free pascal compiler, RTL and FCL.

I suppose that there will be some kind of compiler switch allowing for selecting whether or not to use the "new string" feature.

-Michael

Reply by email

Martin Schreiber
to Martin Schreiber: I don't refer to Lazarus but to Free Pascal compiler, RTL and FCL. Martin
Show quoted text 6 lines
On 10/20/2011 09:43 AM, Martin Schreiber wrote: > I don't refer to Lazarus but to Free pascal compiler, RTL and FCL. > I suppose that there will be some kind of compiler switch allowing for selecting whether or not to use the "new string" feature.

That does not change the possibility that FPC compiler, RTL and FCL will be less stable than now because of the greater complexity and because of the possible new bugs.

Martin

Reply by email

Martin Schreiber
to Martin Schreiber
Martin Schreiber wrote 10 lines
> On 10/20/2011 09:43 AM, Martin Schreiber wrote: > > I don't refer to Lazarus but to Free pascal compiler, RTL and FCL. > > > I suppose that there will be some kind of compiler switch allowing for > selecting whether or not to use the "new string" feature. > That does not change the possibility that FPC compiler, RTL and FCL will be less stable than now because of the greater complexity and because of the possible new bugs.

Hmm, "now" is wrong, should be "before the cpstrnew merge"...

Martin

Reply by email

Žilvinas Ledas
to Felipe Monteiro de Carvalho: 2011/10/19 ?ilvinas Ledas : I am mostly interested in LowerCase / UpperCase. Could you…

Hi,

Felipe Monteiro de Carvalho wrote 22 lines
Hello, 2011/10/19 ?ilvinas Ledas: > I am native Lithuanian so I think can help at least providing info, but I > must understand what is the problem first. I am mostly interested in LowerCase / UpperCase. Could you explain how it works in Lithuanian and provide test cases for it? Test cases should be in this format: AssertStringOperationUTF8LowerCase('Unicode 0460 UTF8LowerCase', '', '????????????????', '????????????????'); Even better if they are in patches to the file lazarus/tests/lazutils/testunicode.pas First param is the label, the second the locale (in this case maybe something like 'lt', what is the ISO identifier for lituanian? Then UpperCase and then LowerCase. And try to make some tricky tests, to defeat partial implementations. 3 tests for lowercase and 3 for uppercase should be enough

This should be easy. This week I have a lot of things to do but I'll try to look into this next week!

Regards,
?ilvinas Ledas

Reply by email

Hans-Peter Diettrich
to Michael Schnell: I don't consider the current state of Lazarus "stable", as IMHO the "UTF8 in type…
Show quoted text 6 lines
On 10/20/2011 09:18 AM, Martin Schreiber wrote: > Now the FPC team destroyed a stable product in favor of > Delphi string compatibility. I don't consider the current state of Lazarus "stable", as IMHO the "UTF8 in type ANSIString" paradigm (seemingly forced by the underlying FPC version) is too "special" to stay.

It's sufficient to agree that all (displayed) strings in the LCL contain UTF-8 text, regardless of their type name (string types currently are alias).

As I don't have a Delphi > 2009, I have no idea if the "new" Delphi way to handle Unicode is desirable or even this is not meant as a criticism whatsoever.

Delphi allows for an UTF8String type, but this one is (or has to be) converted into UnicodeString all the time. The Delphi RTL only supports UnicodeString (UTF-16) and native AnsiStrings (of CP_ACP), all other encodings are not really supported, except for UTF-16 conversion. MBCS are supported only as far eastern DBCS, not for UTF-8 (I wonder what a Linux version will bring).

Functions with more than one (Ansi)String argument deserve special care, the *user* is responsible to only supply strings of the same encoding, or has to force the use of the UnicodeString versions by e.g. typecasts.

I.e. it's highly discouraged to use any but CP_ACP or UTF-16 strings, except for corner cases (file I/O...).

When FPC follows the new Delphi model, the LCL has to be ported to all strings containing UTF-16 - everything else will not work properly or causes many implicit conversions. This may require some work, and results in two incompatible versions (legacy Ansi/UTF-8 and new Unicode/UTF-16), and will not please all Linux (POSIX) users. IMO Linux is not a problem with the LCL, since the currently required UTF-8/16 conversions with external function calls are neglectable (on my Windows system).

DoDi

Reply by email

Michael Schnell
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote
It's sufficient to agree that all (displayed) strings in the LCL contain UTF-8 text, regardless of their type name (string types currently are alias).

And thus functions like pos(), length() and myString[i] work on UTF-8 code bytes rather than on (displayed) characters.

Agreeable for thought who know just use ASCII (no Germans, ...) and though who have a decent knowledge on Unicode.

All others are fooled.

-Michael

Reply by email

Felipe Monteiro de Carvalho
to Michael Schnell
Michael Schnell wrote
All others are fooled.

No, they aren't. Please stop repeating this. I think you have already sent 10 messages in various threads saying that people are naturally unable to use UTF-8.

This is not true. My students from the 2nd year of engineering learned alone how to use UTF-8 properly. People asking questions on the forum learned how to use it. I so far I have seen no single person which has such a problem with UTF-8 that it is mentally blocked from learning it, even while this same person can use UCS-2 fluently.

This is all just fiction. Real experience shows that people can easily learn to use UTF-8.

Felipe Monteiro de Carvalho

Reply by email

Michael Schnell
to Felipe Monteiro de Carvalho: No, they aren't. Please stop repeating this. I think you have already sent 10 messages in…
Felipe Monteiro de Carvalho wrote
On Thu, Oct 20, 2011 at 2:54 PM, Michael Schnell wrote: > All others are fooled. This is not true. My students from the 2nd year of engineering learned alone how to use UTF-8 properly.

That is exactly what I meant to say. Those who do learn how to deal with Unicode might be very happy to keep in mind the Unicode encoding with all string operations.

And if your opinion is that everybody, who wants to program with Lazarus, is happy when he also learns the ways of Unicode, I will not contradict.

But IMHO Lazarus should be (at least) as easy to use as Java and friends and not provide additional traps for the Unicode-illiterates.

(I once proposed to drop the support for myString[i] or for the "char" type altogether to prevent some of these traps, but supposedly this is a silly idea.)

-Michael

Reply by email

Felipe Monteiro de Carvalho
to Michael Schnell
Michael Schnell wrote
But IMHO Lazarus should be (at least) as easy to use as Java and friends and not provide additional traps for the Unicode-illiterates.

This argumentation is ridiculous, string usage in Java has tons of traps. To start with it is a special class type with special handling and immutable o.O Then you have no var parameters to pass them around (and even if you had, they are immutable)...etc

But let's go back to real arguments: Do you have any big applications written in Lazarus? If you had, how happy would you be having to convert them from utf-8 to utf-16?

Felipe Monteiro de Carvalho

Reply by email

Michael Schnell
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
Do you have any big applications written in Lazarus? If you had, how happy would you be having to convert them from utf-8 to utf-16?

I never voted for a UTF-16 - Lazarus.

In fact I have lots of applications done in Delphi < 2009 and thus not Unicode aware at all but using just 8 bit "fixed locale" ANSI encoded strings.

I was happily converting some of those to the pre-Unicode of Lazarus (for having them run on Linux).

I was not at all happy trying to convert them to the "always UTF-8" version of Lazarus.

I am sure that I will not be more happy trying to convert them to a hypothetical "always UTF-16" version of Lazarus.

I have no idea how happy I would be trying to convert them to a Unicode aware Delphi version > 2009.

And of course I have no idea at all how happy I would be trying to convert them to an upcoming "new Delphi String" version of Lazarus.

-Michael

Reply by email

Felipe Monteiro de Carvalho
to Michael Schnell
Michael Schnell wrote
I was not at all happy trying to convert them to the "always UTF-8" version of Lazarus.

Well, here is the surprise now: utf-8 was chosen exactly to facilitate porting old applications while still supporting all of the Unicode standard.

Length does not give the number of chars? No problem:

uses lazutf8;
function UTF8Length(const s: string): PtrInt;

How to iterate through chars? Using this:

function UTF8CharacterLength(p: PChar): integer;

How to find the n-th char?

// find the n-th UTF8 character, ignoring BIDI
function UTF8CharStart(UTF8Str: PChar; Len, CharIndex: PtrInt): PChar;
// find the byte index of the n-th UTF8 character, ignoring BIDI (byte
len of substr)
function UTF8CharToByteIndex(UTF8Str: PChar; Len, CharIndex: PtrInt): PtrInt;

Having problems in Pos, Copy, Delete or Insert? Just replace with these:

function UTF8Pos(const SearchForText, SearchInText: string): PtrInt;
function UTF8Copy(const s: string; StartCharIndex, CharCount: PtrInt): string;
procedure UTF8Delete(var s: String; StartCharIndex, CharCount: PtrInt);
procedure UTF8Insert(const source: String; var s: string;
StartCharIndex: PtrInt);

The switch is really easy. There are routines which are equivalent to all operations done previously.

Felipe Monteiro de Carvalho

Reply by email

Luca Olivetti
to Felipe Monteiro de Carvalho

Al 20/10/2011 16:34, En/na Felipe Monteiro de Carvalho ha escrit:

The switch is really easy. There are routines which are equivalent to all operations done previously.

But you have to manually (or semi-automatically) do it, which is a lot of work and possibly error prone.
While, with utf-16, you shouldn't change any routine name at all, unless you have to deal with characters outside the BMP.
According to this message
https://forums.codegear.com/message.jspa?messageID=399964#399964

"Additionally, 16 bits is enough to cover the BMP, Basic Multilingual Plane, which encompasses the majority of today's most widely used languages. Only when you get to more advanced codepoints in some of the far-eastern languages, or are needing to encode dead languages such as Egyption hieroglyphics do you need more than 16 bits."

Bye

Luca Olivetti Wetron Automation Technology http://www.wetron.es Tel. +34 935883004 (Ext.133) Fax +34 935883007

Reply by email

Mattias Gaertner
to Michael Schnell: That is exactly what I meant to say. Those who do learn how to deal with Unicode might be…

Michael Schnell hat am 20. Oktober 2011 um 15:10
geschrieben:

Show quoted text 9 lines
On 10/20/2011 02:55 PM, Felipe Monteiro de Carvalho wrote: > On Thu, Oct 20, 2011 at 2:54 PM, Michael Schnell? wrote: >> All others are fooled. > This is not true. My students from the 2nd year of engineering learned > alone how to use UTF-8 properly. That is exactly what I meant to say. Those who do learn how to deal with Unicode might be very happy to keep in mind the Unicode encoding with all string operations.?

?
?

Show quoted text 7 lines
And if your opinion is that everybody, who wants to program with Lazarus, is happy when he also learns the ways of Unicode, I will not contradict. But IMHO Lazarus should be (at least) as easy to use as Java and friends and not provide additional traps for the Unicode-illiterates.?

What Java do you have in mind?
Last time I used Oracle/Sun Java it still used 2byte char and you need to set the compiler/IDE to UTF8, otherwise your source code is not portable. We have a lot of students writing java programs under Windows, then wondering why their programs create garbage under Linux. Often they say: Linux has problems with unicode. Reason: teachers think that unicode is so simple under java, so they don't explain it.
?
?

(I once proposed to drop the support for myString[i] or for the "char" type altogether to prevent some of these traps, but supposedly this is a silly idea.)

If you have students that stupid, then don't tell them about the [] operator.

Mattias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111020/034c3adb/attachment.html>

Reply by email

Felipe Monteiro de Carvalho
to Luca Olivetti: Al 20/10/2011 16:34, En/na Felipe Monteiro de Carvalho ha escrit: But you have to…
Luca Olivetti wrote
But you have to manually (or semi-automatically) do it, which is a lot of work and possibly error prone. While, with utf-16, you shouldn't change any routine name at all, unless you have to deal with characters outside the BMP.

You say so, but while I cannot comment with certainty since I have never used the Unicode Delphi, from what I read people had major difficulties doing the migration. It was not at all easy. While for me the migration from ansi to utf-8 was trivially easy.

Changing the size of Char is not just small detail, this breaks *a lot* of code. Any kind of memory operations such as Move will fail because the char size changed.

Not to mention people that were using PChar to address memory which is not really a string =D suddenly the steps duplicate in size and your whole memory layout changes...

Felipe Monteiro de Carvalho

Reply by email

Felipe Monteiro de Carvalho
to Michael Schnell: And thus functions like pos(), length() and myString[i] work on UTF-8 code bytes rather…
Michael Schnell wrote
And thus functions like pos(), length() and myString[i] work on UTF-8 code bytes rather than on (displayed) characters.

Characters can be composed by separate codepoints for accent + character (so at least 4 bytes in UTF-16). So if you write code which depends on [] indexing characters your code will fail miserably in this case.

Mac OS X uses the decomposed form in UTF-8 to store filenames, which is rather unpleasant. If you convert this to UTF-16 for further work the text will not magically get composed, although one could pass it through a composing pre-processor.

Felipe Monteiro de Carvalho

Reply by email

Hans-Peter Diettrich
to Felipe Monteiro de Carvalho: You say so, but while I cannot comment with certainty since I have never used the Unicode…
Show quoted text 10 lines
On Thu, Oct 20, 2011 at 5:30 PM, Luca Olivetti wrote: > But you have to manually (or semi-automatically) do it, which is a lot of > work and possibly error prone. > While, with utf-16, you shouldn't change any routine name at all, unless you > have to deal with characters outside the BMP. You say so, but while I cannot comment with certainty since I have never used the Unicode Delphi, from what I read people had major difficulties doing the migration. It was not at all easy. While for me the migration from ansi to utf-8 was trivially easy.

The Ansi/UTF-16 migration is much easier than a migration to UTF-8. When your legacy code can assume that every (visible) character is a Char, in an SBCS codepage, this is not different in UTF-16. But the same is not true for Ansi SBCS codepages whose characters can translate into multi-byte sequences in UTF-8.

Changing the size of Char is not just small detail, this breaks *a lot* of code. Any kind of memory operations such as Move will fail because the char size changed.

Why would *application* code ever do low-level fiddling with *managed* strings???

Not to mention people that were using PChar to address memory which is not really a string =D suddenly the steps duplicate in size and your whole memory layout changes...

Then replace all occurences of String by AnsiString, and Char by AnsiChar (global find&replace). And replace all (eventual) usages of UTF8String by AnsiString, to prevent possible encoding conversions. Then all your code should work as before. Problems may arise from standard text components (TStrings...), when these are not also available in Ansi versions - but this only affects the runtime, due to implicit conversions. This is where the RTL and FCL deserve some more considerations, and the future will tell...

DoDi

Reply by email

Graeme Geldenhuys
to Luca Olivetti: Al 20/10/2011 16:34, En/na Felipe Monteiro de Carvalho ha escrit: But you have to…
Luca Olivetti wrote 6 lines
"Additionally, 16 bits is enough to cover the BMP, Basic Multilingual Plane, which encompasses the majority of today's most widely used languages. Only when you get to more advanced codepoints in some of the far-eastern languages, or are needing to encode dead languages such as Egyption hieroglyphics do you need more than 16 bits."

That is such a rubbish statement! More and more information is being added outside the Unicode's BMP. Emoticons, Science and Maths symbols, Map Symbols (often seen in GPS applications), Music notes etc etc. So it's not just far-eastern or "dead" languages any more... Using the Supplementary Plane of Unicode will become a lot more used in the near future. So UTF-16's usage of surrogate pairs will become more common place. And this is where UTF-8 will shine once again, because nothing will need changing in the programmers code - selecting a BMP or Supplementary code point is identical. Programmers using UTF-16 often don't bother checking for surrogate pairs, treating UTF-16 like UCS2 - BIG MISTAKE! This is why I think UTF-8 is a much safer choice.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Graeme Geldenhuys
to Hans-Peter Diettrich: The Ansi/UTF-16 migration is much easier than a migration to UTF-8. When your legacy code…
Hans-Peter Diettrich wrote
your legacy code can assume that every (visible) character is a Char, in an SBCS codepage, this is not different in UTF-16.

Rookie mistake!!! You forgot surrogate pairs in UTF-16. Think outside the Unicode BMP where a "visible" character will be 4-bytes, thus two UTF-16 Char values. As as I mentioned earlier, most programmers using UTF-16 treat it like UCS2, forgetting that they need to check for surrogate pairs too.

Now in UTF-8, this is not a a visible character
in the BMP or Supplementary Plane is a identical process, no special checking is required. Thus making UTF-8 much easier and safer to use.

I've ported enough Delphi code to FPC + fpGUI where UTF-8 is used for Unicode support. I fully agree with Felipe, using UTF-8 is much easier with legacy code that UTF-16.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Michael Schnell
to Felipe Monteiro de Carvalho: Well, here is the surprise now: utf-8 was chosen exactly to facilitate porting old…
Felipe Monteiro de Carvalho wrote
Length does not give the number of chars? No problem:

As said: Of course this is no problem for those who do are aware that they are dealing with Unicode and not with displayed characters. This of course includes myself when doing new code from scratch. But this does not include the persons I mentioned before and it does not include me when porting legacy code.

-Michael

Reply by email

Michael Schnell
to Felipe Monteiro de Carvalho: You say so, but while I cannot comment with certainty since I have never used the Unicode…
Felipe Monteiro de Carvalho wrote
Changing the size of Char is not just small detail, this breaks *a lot* of code. Any kind of memory operations such as Move will fail because the char size changed.

Of course you are right, but "move" and friends is "hardware-near programming" for this who know what they are doing. but basic (legacy) string operations like "myChar := myString[i]" is "office-level programming" and thus should work as a dummy expects.

-Michael

Reply by email

Michael Schnell
to Graeme Geldenhuys: Rookie mistake!!! You forgot surrogate pairs in UTF-16. Think outside the Unicode BMP…
Graeme Geldenhuys wrote
You forgot surrogate pairs in UTF-16. Think outside the Unicode BMP where a "visible" character will be 4-bytes, thus two UTF-16 Char values.

Regarding this, there seemingly is no help at all :( (I understand that even in full 32 Unicode there are such pairs, creating characters that are even maybe defined as completely different 32 Bit Unicode as well)

But in fact I up til now never came across any situation requiring non-BMP encoding.

-Michael

Reply by email

Michael Schnell
to Graeme Geldenhuys: That is such a rubbish statement! More and more information is being added outside the…
Graeme Geldenhuys wrote
That is such a rubbish statement! More and more information is being added outside the Unicode's BMP. Emoticons, Science and Maths symbols, Map Symbols (often seen in GPS applications), Music notes etc etc.

Those who deal with this of course need to know what they are doing.

But those who use "normal" non-English (ASCII) languages (I understand that this is what BMP means) and don't want to deal with such things, are (maybe unnecessarily ) forced into hell by "the UTF-8 in ANSIString paradigm" .

-Michael

Reply by email

Michael Schnell
to Mattias Gaertner: Michael Schnell hat am 20. Oktober 2011 um 15:10 geschrieben: ? ? What Java do you have…
Mattias Gaertner wrote
Often they say: Linux has problems with unicode. Reason: teachers think that unicode is so simple under java, so they don't explain it.

I see. Obviously a similar problem as with Delphi. (If E. in fact (like promised some time ago) creates a Delphi that compiles for Linux, I am curious how this is handled.)

If you have students that stupid, then don't tell them about the [] operator.

:) :) :)

-Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111021/1c2c08cc/attachment.html>

Reply by email

Graeme Geldenhuys
to Michael Schnell: Regarding this, there seemingly is no help at all :( (I understand that even in full 32…
Michael Schnell wrote
But in fact I up til now never came across any situation requiring non-BMP encoding.

We use the Science and Maths symbols define outside the BMP all the time in our products. Why use images (old school style) when font symbols (today's style) can do the exact same think, but easier. Plus you get the benefit that you can copy & paste text with math or science symbols without problems.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Hans-Peter Diettrich
to Graeme Geldenhuys: Rookie mistake!!! You forgot surrogate pairs in UTF-16. Think outside the Unicode BMP…
Show quoted text 5 lines
On 2011-10-21 00:20, Hans-Peter Diettrich wrote: > your legacy code can assume that every (visible) character is a Char, in > an SBCS codepage, this is not different in UTF-16. Rookie mistake!!! You forgot surrogate pairs in UTF-16.

Which Ansi characters translate into surrogate pairs?

Now in UTF-8, this is not a a visible character in the BMP or Supplementary Plane is a identical process, no special checking is required. Thus making UTF-8 much easier and safer to use.

Please specify "Finding", a code snippet would be nice.

I've ported enough Delphi code to FPC + fpGUI where UTF-8 is used for Unicode support. I fully agree with Felipe, using UTF-8 is much easier with legacy code that UTF-16.

This only demonstrates that UTF-16 has not been supported sufficiently in FPC, until now. Give an example of UTF-8 code, which would become *more* complicated with UTF-16.

DoDi

Reply by email

Graeme Geldenhuys
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote
Please specify "Finding", a code snippet would be nice.

Knock yourself out...

https://github.com/graemeg/fpGUI/blob/master/src/corelib/fpg_stringutils.pas

Take a look at UTF8Copy() or UTF8Insert() etc.

in FPC, until now. Give an example of UTF-8 code, which would become *more* complicated with UTF-16.

Consider a Copy() type function where you want to copy a Unicode codepoint (think single character as you see on the screen - ignoring combining diacritics for now) out from a string. UTF8Copy() as defined above will do that correctly, irrespective if the codepoint is in the BMP or Supplementary Plane or if the character is represented by 1,2,3 or 4 bytes in length.

With UTF-16 you need to check if the UTF-16 string is Little Indian or Big Indian (UTF-16BE or UTF-16LE), whether the codepoint has a surrogate pair or not. All in all, a lot more complex than UTF-8.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Hans-Peter Diettrich
to Graeme Geldenhuys: That is such a rubbish statement! More and more information is being added outside the…
Show quoted text 11 lines
On 2011-10-20 17:30, Luca Olivetti wrote: > "Additionally, 16 bits is enough to cover the BMP, Basic Multilingual > Plane, which encompasses the majority of today's most widely used > languages. Only when you get to more advanced codepoints in some of the > far-eastern languages, or are needing to encode dead languages such as > Egyption hieroglyphics do you need more than 16 bits." That is such a rubbish statement! More and more information is being added outside the Unicode's BMP. Emoticons, Science and Maths symbols, Map Symbols (often seen in GPS applications), Music notes etc etc.

Now also tell us how application code is affected by such astral codepoints, and how these are handled easier in UTF-8 than in UTF-16.

DoDi

Reply by email

Michael Schnell
to Graeme Geldenhuys: We use the Science and Maths symbols define outside the BMP all the time in our products.…
Graeme Geldenhuys wrote
We use the Science and Maths symbols define outside the BMP all the time in our products.

So with these projects you obviously are a "Unicode aware" programmer and don't qualify for the group of "office" programmers that (IMHO) should be enabled to do theirs stuff without being forced to think about "displayable character encoding" stuff.

-Michael

Reply by email

Graeme Geldenhuys
to Michael Schnell
Michael Schnell wrote
So with these projects you obviously are a "Unicode aware" programmer and don't qualify for the group of "office" programmers that (IMHO)

I don't have to think about anything special when working with Unicode text. I simply use the string manipulation function as defined in the fpGUI framework, and not the ones defined in FPC's RTL. The fpGUI framework handles the rest for me.

I'm even considering renaming all the UTF8xxx string manipulation functions in fpGUI to something like fpgXXXX (eg: fpgCopy() or fpgInsert()) because I really don't think the programmer needs to know that fpGUI uses UTF-8 internally. If you use the string functions as defined in fpGUI, your code will work.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Michael Lutz
to Hans-Peter Diettrich: The Ansi/UTF-16 migration is much easier than a migration to UTF-8. When your legacy code…
Hans-Peter Diettrich wrote
The Ansi/UTF-16 migration is much easier than a migration to UTF-8. When your legacy code can assume that every (visible) character is a Char, in an SBCS codepage, this is not different in UTF-16.

Ever heard of decomposed characters? In *no* Unicode encoding you can ever assume a single visible character is made up of only a single code point (Char as you call it). Even if you normalize all external text, you'd still have to deal with those characters as not every valid combination of base character and diacriticals has a precomposed form.

Don't even think about collation, sorting, upper/lower-casing etc, there's a reason the ICU library comes with 16 MB of data in addition to the code.

Conclusion: Every Unicode encoding has variable length characters. Code points in UTF-32 are of fixed size, in UTF-16 come in two sizes, and in UTF-8 come in four sizes (not six as the Unicode standard chose not utilize a full 32-bit numerical space). Additionally, UTF-16 and UTF-32 are not endian neutral.

Conclusion 2: For storing a single visible character, a simple char/wchar_t/wxChar/wxUniChar/whatever variable is not enough. You always need a string to cater for decomposed characters.

Michael Lutz

Reply by email

Žilvinas Ledas
to Michael Schnell: Of course you are right, but "move" and friends is "hardware-near programming" for this…

Hello,

Michael Schnell wrote 5 lines
Of course you are right, but "move" and friends is "hardware-near programming" for this who know what they are doing. but basic (legacy) string operations like "myChar := myString[i]" is "office-level programming" and thus should work as a dummy expects.

What if a file on the user computer has 4byte [visible] character as 8th character and you, for example want to get 8 character file name? In this case you split that 4 byte character and have garbage. What it user inputs in your text field (or a command line parameter or anywhere else) a string containing 4 byte character and you split that string on that character? (For example when showing some kind of summary of his input.) Don't forget that user can input characters by copy-pasting them from the web, not only using his keyboard!

So, if you want to write PROFESSIONAL software with any user input - you must handle 4 byte characters at every place you get user input. Otherwise you leave a chance to get and show to the user garbage. Is this really easier than using UTF8 everywhere?

My personal experience: I am maintaining (as a hobby project) multi-language dictionary program (a screen-shoot: http://2.bp.blogspot.com/_3-IaodGIbVQ/TMHY-l9M4sI/AAAAAAAAAak/AbtShWq0ZUQ/s1600/KZod_screen_win7.png ) and it involves quite a bit of [multilingual] string manipulation and when I did migration from delphi to Lazarus I didn't know about requirement that all (GUI) strings must be UTF8 and I had no problems migrating! Yes, afterwards I tweaked some calls to RTL (mostly file handling) functions that expected to get ANSI encoding, but this is not a problem of UTF8, but or RTL being (mostly) ansi.

Regards,
?ilvinas Ledas

Reply by email

Michael Schnell
to Žilvinas Ledas
?ilvinas Ledas wrote
What if a file on the user computer has...

If you deal with the content of files you did not write yourself, you of course need to deal with whatever encoding same has been done in (maybe its EBCDIC :) ). This is unavoidable and if you are so unhappy that you need to consider that the file is done in Unicode, you of course need to upgrade to being a Unicode expert.

But if you just deal with the user's GUI input and output and with files that you wrote yourself in some default encoding code the language tools define, IMHO a decent language should do whatever possible to hide the complexity.

As said: I'm not sure to what extent this is possible and whether Delphi does a good job here, so I don't intend to question any decision done by the Lazarus team now (for FPC without "new" strings) or in future with FPC with whatever implementation of a "new" string feature).

-Michael

Reply by email

Michael Lutz
to Michael Schnell
Michael Schnell wrote
But if you just deal with the user's GUI input and output and with files that you wrote yourself in some default encoding code the language tools define, IMHO a decent language should do whatever possible to hide the complexity.

You'd advocate for fpc/Lazarus to normalize all incoming and outgoing file names then? If you write a file with a file name in unicode NFC in OS X and read the file name back from the OS, you'll get a NFD string returned, which means a normalization-unaware compare function will not do what you'd expect.

Michael Lutz

Reply by email

Michael Lutz
to Michael Schnell: Why are they so silly ? -Michael
Michael Schnell wrote 5 lines
On 10/20/2011 10:26 PM, Felipe Monteiro de Carvalho wrote: > Mac OS X uses the decomposed form in UTF-8 to store filenames, which > is rather unpleasant. Why are they so silly ?

What's silly about that? If they'd store it in precomposed form (NFC) instead, you still can't use a simple string compare unless you normalize all strings. And even better, some characters used in some languages simply have no precomposed form at all, which means you'll always have to be prepared to handle characters composed of several Unicode code points.

Michael Lutz

Reply by email

Michael Schnell
to Michael Lutz: You'd advocate for fpc/Lazarus to normalize all incoming and outgoing file names then? If…
Michael Lutz wrote 5 lines
If you write a file with a file name in unicode NFC in OS X and read the file name back from the OS, you'll get a NFD string returned, which means a normalization-unaware compare function will not do what you'd expect.

...as already mentioned in another message in this thread OSX does really silly stuff regarding file names.

How does their object pascal handle this ?

-Michael

Reply by email

Mattias Gaertner
to Michael Schnell

Michael Schnell hat am 21. Oktober 2011 um 17:23
geschrieben:

Show quoted text 8 lines
On 10/21/2011 04:13 PM, Michael Lutz wrote: > If you write a file with a file name in unicode NFC in OS X > and read the file name back from the OS, you'll get a NFD string returned, > which means a normalization-unaware compare function will not do what > you'd expect. > ...as already mentioned in another message in this thread OSX does really silly stuff regarding file names.?

The normalization is not silly. ?
The really silly thing is that by default their file system is case insensitive, while many command line tools are not.?
?
?

How does their object pascal handle this ?

I don't know what they did, but I know from Lazarus:It's not a big deal. Lazarus works since years on OS X and only needed a function to compare file names, which calls the OS X function. Of course Lazarus already supported Linux. It can be hard to port a Windows application to OS X.?

Mattias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111021/b1f711ad/attachment.html>

Reply by email

Hans-Peter Diettrich
to Graeme Geldenhuys: I don't have to think about anything special when working with Unicode text. I simply use…
Show quoted text 9 lines
On 2011-10-21 10:31, Michael Schnell wrote: > So with these projects you obviously are a "Unicode aware" programmer > and don't qualify for the group of "office" programmers that (IMHO) I don't have to think about anything special when working with Unicode text. I simply use the string manipulation function as defined in the fpGUI framework, and not the ones defined in FPC's RTL. The fpGUI framework handles the rest for me.

Did you ever have a look at Delphi StrUtils.pas?
Why reinvent the wheel, when functions already exist for some purpose?

The "Ansi" prefix can be removed in an environment where the encoding of the string arguments is known (e.g. fixed to UTF-8).

The bad news about new Delphi strings is the addition (overload) of functions with RawByteString arguments, which *take* strings of any encoding, but then *ignore* that encoding. These versions certainly must fail for all MBCS encodings :-(

DoDi

Reply by email

Hans-Peter Diettrich
to Graeme Geldenhuys: Knock yourself out... https://github.com/graemeg/fpGUI/blob/master/src/corelib/fpg_stringu…
Show quoted text 10 lines
On 2011-10-21 10:19, Hans-Peter Diettrich wrote: > Please specify "Finding", a code snippet would be nice. Knock yourself out... https://github.com/graemeg/fpGUI/blob/master/src/corelib/fpg_stringutils.pas Take a look at UTF8Copy() or UTF8Insert() etc.

I didn't mean the implementation, but the *task* to perform in application code.

Show quoted text 6 lines
> in FPC, until now. Give an example of UTF-8 code, which would become > *more* complicated with UTF-16. Consider a Copy() type function where you want to copy a Unicode codepoint (think single character as you see on the screen - ignoring combining diacritics for now) out from a string.

Again, *why* would you ever want to do that? It sounds to me like extracting bits from floating point values :-(

UTF8Copy() as defined above will do that correctly, irrespective if the codepoint is in the BMP or Supplementary Plane or if the character is represented by 1,2,3 or 4 bytes in length.

Why restrict such a function to UTF-8? For working with *logical* characters a set of functions is needed, that do not rely on character indices. A StartIndex parameter IMO indicates bad design :-( The functions can be easily overloaded to work with AnsiChar and WideChar string arguments, or even UCS4Char, if you like.

With UTF-16 you need to check if the UTF-16 string is Little Indian or Big Indian (UTF-16BE or UTF-16LE),

This has to be done only on input from an file, where the encoding should be converted into the internal representation for every external encoding.

BTW, its "Endian", not "Indian" nor "Chinese" ;-)

whether the codepoint has a surrogate pair or not. All in all, a lot more complex than UTF-8.

Sorry, UTF-8 and UTF-16 only provide different encodings for the same Unicode codepoints. Mixing Char and Codepoint indices and counts never is a good idea. With that in mind it's no problem to perform the same task on any encoding.

DoDi

Reply by email

Hans-Peter Diettrich
to Michael Lutz: Ever heard of decomposed characters? In *no* Unicode encoding you can ever assume a…
Show quoted text 6 lines
Am 21.10.2011 00:20 schrieb Hans-Peter Diettrich: > The Ansi/UTF-16 migration is much easier than a migration to UTF-8. When > your legacy code can assume that every (visible) character is a Char, in > an SBCS codepage, this is not different in UTF-16. Ever heard of decomposed characters?

Right, that's one of the strange looking features of Unicode, related to *language* conventions.

Don't even think about collation, sorting, upper/lower-casing etc, there's a reason the ICU library comes with 16 MB of data in addition to the code.

Right, see above.

For writing applications that are aware of different languages, Unicode by itself is not very helpful - but Unicode allows to implement and use libraries, dealing with everything beyond codepoints.

Show quoted text 5 lines
Conclusion: Every Unicode encoding has variable length characters. Code points in UTF-32 are of fixed size, in UTF-16 come in two sizes, and in UTF-8 come in four sizes (not six as the Unicode standard chose not utilize a full 32-bit numerical space). Additionally, UTF-16 and UTF-32 are not endian neutral.

Data can be compressed in various ways, text is only one kind of such data. An application should select the most appropriate text encoding, and use exactly this one internally.

Conclusion 2: For storing a single visible character, a simple char/wchar_t/wxChar/wxUniChar/whatever variable is not enough. You always need a string to cater for decomposed characters.

Right, outside SBCS the code has to distinguish between logical and physical characters, indices and counts. IMO it's not normally required to store exactly one logical character, so that (sub)strings should be used everywhere.

E.g. it may be more efficient to cut an string at the place, where a certain pattern has been found, into two or three substrings, and then continue working with the preceding or following string. This eliminates the need to find the starting position again, based on an eventually returned logical character count.

AFAIK Java uses powerful substrings, which are references into the same string, with their own physical offsets and sizes, reducing runtime and storage requirements. Imagine what could be done with an equivalent SubString type in OPL, that can be used to refer to the preceding, matched and following parts of the entire string, without iterating again over the entire string. E.g.

   function Match(str, pattern: string): SubString;
   function Match(str, start, delim: string): SubString;

would allow for simple implementations of:

   MatchNext(str, substr): SubString;
   Replace(str, substr, newstr);
   Leader(str, substr): SubString;
   Trailer(str, substr): SubString;

etc.

DoDi

Reply by email

Hans-Peter Diettrich
to Michael Schnell: Of course you are right, but "move" and friends is "hardware-near programming" for this…
Show quoted text 9 lines
On 10/20/2011 09:42 PM, Felipe Monteiro de Carvalho wrote: > > Changing the size of Char is not just small detail, this breaks *a > lot* of code. Any kind of memory operations such as Move will fail > because the char size changed. Of course you are right, but "move" and friends is "hardware-near programming" for this who know what they are doing. but basic (legacy) string operations like "myChar := myString[i]" is "office-level programming" and thus should work as a dummy expects.

Simple solution: use UTF-32 encoding :-)

It's only a matter of optimization: save memory with more compressed encodings, or save coding time?

DoDi

Reply by email

Hans-Peter Diettrich
to Žilvinas Ledas: What if a file on the user computer has 4byte [visible] character as 8th character and…
Show quoted text 12 lines
Hello, On 2011-10-21 10:43, Michael Schnell wrote: > Of course you are right, but "move" and friends is "hardware-near > programming" for this who know what they are doing. but basic (legacy) > string operations like "myChar := myString[i]" is "office-level > programming" and thus should work as a dummy expects. > What if a file on the user computer has 4byte [visible] character as 8th character and you, for example want to get 8 character file name? In this case you split that 4 byte character and have garbage.

Then you (or your boss) didn't understand the meaning of "4 characters". (Logical) characters are different from physical Chars, in every MBCS codepage.

Show quoted text 5 lines
What it user inputs in your text field (or a command line parameter or anywhere else) a string containing 4 byte character and you split that string on that character? (For example when showing some kind of summary of his input.) Don't forget that user can input characters by copy-pasting them from the web, not only using his keyboard!

See above. With proportial fonts, counting characters is a bad idea, instead the width of the displayed string (in pixels) should be used. Then you also can deal with languages and character sets, which use ligatures and the like. Even with monospaced fonts the "characters" (glyphs) can have a different width, in multiples of the basic width, e.g. for Chinese or other eastern character sets.

So, if you want to write PROFESSIONAL software with any user input - you must handle 4 byte characters at every place you get user input.

Counting characters then is a bad idea, see above.

Show quoted text 6 lines
Otherwise you leave a chance to get and show to the user garbage. Is this really easier than using UTF8 everywhere? My personal experience: I am maintaining (as a hobby project) multi-language dictionary program (a screen-shoot: http://2.bp.blogspot.com/_3-IaodGIbVQ/TMHY-l9M4sI/AAAAAAAAAak/AbtShWq0ZUQ/s1600/KZod_screen_win7.png

Great :-)

Show quoted text 6 lines
) and it involves quite a bit of [multilingual] string manipulation and when I did migration from delphi to Lazarus I didn't know about requirement that all (GUI) strings must be UTF8 and I had no problems migrating! Yes, afterwards I tweaked some calls to RTL (mostly file handling) functions that expected to get ANSI encoding, but this is not a problem of UTF8, but or RTL being (mostly) ansi.

From which Delphi version did you migrate?
What encoding did you use in Delphi?

DoDi

Reply by email

Hans-Peter Diettrich
to Michael Lutz: You'd advocate for fpc/Lazarus to normalize all incoming and outgoing file names then? If…
Show quoted text 8 lines
Am 21.10.2011 15:02 schrieb Michael Schnell: > But if you just deal with the user's GUI input and output and with files > that you wrote yourself in some default encoding code the language tools > define, IMHO a decent language should do whatever possible to hide the > complexity. You'd advocate for fpc/Lazarus to normalize all incoming and outgoing file names then?

Please distinguish between file names and content. Filenames are subject to platform conventions, with e.g. case sensitivity and directory separators. File content and encoding instead is fully up to the creator.

DoDi

Reply by email

Hans-Peter Diettrich
to Graeme Geldenhuys: That is such a rubbish statement! More and more information is being added outside the…
Show quoted text 11 lines
On 2011-10-20 17:30, Luca Olivetti wrote: > "Additionally, 16 bits is enough to cover the BMP, Basic Multilingual > Plane, which encompasses the majority of today's most widely used > languages. Only when you get to more advanced codepoints in some of the > far-eastern languages, or are needing to encode dead languages such as > Egyption hieroglyphics do you need more than 16 bits." That is such a rubbish statement! More and more information is being added outside the Unicode's BMP. Emoticons, Science and Maths symbols, Map Symbols (often seen in GPS applications), Music notes etc etc.

What do you have in mind, what your code would do with e.g. music notes? Would it ever try to convert these into upper case, or to substitute parts of such strings by text???

You can get rubbish more easily, by random substitution of English words by German or Chinese ones...

Or by parsing C code with a Pascal parser...

DoDi

Reply by email

Hans-Peter Diettrich
to Graeme Geldenhuys: As to not repeat myself, see one of my other replies. - Graeme - fpGUI Toolkit - a…
Show quoted text 6 lines
On 2011-10-21 10:22, Hans-Peter Diettrich wrote: > Now also tell us how application code is affected by such astral > codepoints, and how these are handled easier in UTF-8 than in UTF-16. As to not repeat myself, see one of my other replies.

I didn't ask for a repetition of *what* you did, but for a serious reason *why* you want to do what.

You don't need Unicode for writing bogus applications, it only helps to demonstrate how stupid some ideas are ;-)

DoDi

Reply by email

Žilvinas Ledas
to Hans-Peter Diettrich: Then you (or your boss) didn't understand the meaning of "4 characters". (Logical)…

Hi,

Hans-Peter Diettrich wrote 17 lines
?ilvinas Ledas schrieb: > Hello, > > On 2011-10-21 10:43, Michael Schnell wrote: >> Of course you are right, but "move" and friends is "hardware-near >> programming" for this who know what they are doing. but basic >> (legacy) string operations like "myChar := myString[i]" is >> "office-level programming" and thus should work as a dummy expects. >> > > What if a file on the user computer has 4byte [visible] character as > 8th character and you, for example want to get 8 character file name? > In this case you split that 4 byte character and have garbage. Then you (or your boss) didn't understand the meaning of "4 characters". (Logical) characters are different from physical Chars, in every MBCS codepage.

I know that logical characters are different from physical. I was trying to make a point, that even usint UTF16 you MUST check any string comming trom outside world.

Show quoted text 38 lines
> What it user inputs in your text field (or a command line parameter > or anywhere else) a string containing 4 byte character and you split > that string on that character? (For example when showing some kind of > summary of his input.) Don't forget that user can input characters by > copy-pasting them from the web, not only using his keyboard! See above. With proportial fonts, counting characters is a bad idea, instead the width of the displayed string (in pixels) should be used. Then you also can deal with languages and character sets, which use ligatures and the like. Even with monospaced fonts the "characters" (glyphs) can have a different width, in multiples of the basic width, e.g. for Chinese or other eastern character sets. > So, if you want to write PROFESSIONAL software with any user input - > you must handle 4 byte characters at every place you get user input. Counting characters then is a bad idea, see above. > Otherwise you leave a chance to get and show to the user garbage. Is > this really easier than using UTF8 everywhere? > > My personal experience: I am maintaining (as a hobby project) > multi-language dictionary program (a screen-shoot: > http://2.bp.blogspot.com/_3-IaodGIbVQ/TMHY-l9M4sI/AAAAAAAAAak/AbtShWq0ZUQ/s1600/KZod_screen_win7.png Great :-) > ) and it involves quite a bit of [multilingual] string manipulation > and when I did migration from delphi to Lazarus I didn't know about > requirement that all (GUI) strings must be UTF8 and I had no problems > migrating! Yes, afterwards I tweaked some calls to RTL (mostly file > handling) functions that expected to get ANSI encoding, but this is > not a problem of UTF8, but or RTL being (mostly) ansi. From which Delphi version did you migrate? What encoding did you use in Delphi?

From Delphi 5.
Actually, it was quite do not remember now what I was using :) I think it was a mix of ansi/wide/utf8 strings.

Regards,
?ilvinas Ledas

Reply by email

Marco van de Voort
to Martin Schreiber: That does not change the possibility that FPC compiler, RTL and FCL will be less stable…
Martin Schreiber wrote 7 lines
> > > I suppose that there will be some kind of compiler switch allowing for > selecting whether or not to use the "new string" feature. > That does not change the possibility that FPC compiler, RTL and FCL will be less stable than now because of the greater complexity and because of the possible new bugs.

There is a brand new fixes branch without those changes. Trunk has been broken heavily before early in a cycle.

Reply by email

Michael Schnell
to Hans-Peter Diettrich: Did you ever have a look at Delphi StrUtils.pas? Why reinvent the wheel, when functions…
Hans-Peter Diettrich wrote 7 lines
The bad news about new Delphi strings is the addition (overload) of functions with RawByteString arguments, which *take* strings of any encoding, but then *ignore* that encoding. These versions certainly must fail for all MBCS encodings :-(

Is there an agreement on how this should work ?

function parameter type .... Unicode string type coming in ... actual encoding ID of string coming in -> conversion

1) RawByte ... any .. any -> supposedly no, supposedly keeping the encoding ID
2) not Raw ... Raw ... $FFFF (="RAW") -> ???
3) not Raw ... same ... matching -> obviously No
4) not Raw ... same ... not matching (maybe $FFFF) -> this is an intersexual String what to do ?
5) not Raw ... Raw ... matching to parameter type -> supposedly No
6) not Raw ... Raw ... not $FFFF but not matching the parameter type -> supposedly Yes
7) not Raw ... not Raw but different ... not $FFFF matching its own Type -> supposedly Yes
8) not Raw ... not Raw but different ... not $FFFF matching the Type of the parameter -> this is an intersexual String, not converting it would cure this.
9) not Raw ... not Raw but different ... not $FFFF matching neither -> this is an intersexual String what to do ?
10) not Raw ... not Raw but different ... $FFFF-> this is an intersexual String what to do ?

did I forget any cases ?
-Michael

Reply by email

Michael Schnell
to Michael Lutz: Ever heard of decomposed characters? In *no* Unicode encoding you can ever assume a…
Michael Lutz wrote
Ever heard of decomposed characters?

Handling those in a computer program seems similar to having the computer understand a philosophical text.

Allowing decomposed characters in a string and trying to match them against identically _looking_ single Unicode characters does not seem appropriate for any "normal" software that is not especially made for analyzing linguistic issues.

-Michael

Reply by email

Michael Schnell
to Hans-Peter Diettrich: Then you (or your boss) didn't understand the meaning of "4 characters". (Logical)…
Hans-Peter Diettrich wrote 6 lines
> > What if a file on the user computer has 4byte [visible] character as > 8th character and you, for example want to get 8 character file name? > In this case you split that 4 byte character and have garbage.

For me (and for Linux) a file name does not at all consist of visible characters but is just a sequence of bytes. (AFAIK, with Ext3 any byte is allowed but Zero and "/").

How this byte array is presented on a screen, printed out or obtained from a keyboard is jut up to the program that communicates with the user. Thus it _might_ handle the byte string as if it would be UTF-8 (unless it does not match the appropriate rules), as locale based ANSI or whatever.

For the presentation it of course needs to adhere to the API definition of the WidgetSet used. But this in fact does not have any relation to how the file system works and this what the meaning of the file name really is.

-Michael

Reply by email

Hans-Peter Diettrich
to Michael Schnell: Is there an agreement on how this should work ? function parameter type .... Unicode…
Show quoted text 12 lines
On 10/21/2011 10:24 PM, Hans-Peter Diettrich wrote: > > > The bad news about new Delphi strings is the addition (overload) of > functions with RawByteString arguments, which *take* strings of any > encoding, but then *ignore* that encoding. These versions certainly > must fail for all MBCS encodings :-( > Is there an agreement on how this should work ? function parameter type .... Unicode string type coming in ... actual encoding ID of string coming in -> conversion

I'm not sure what you mean. Whenever a UnicodeString is passed as an argument, the UnicodeString version is called, not the RawByteString version.

When only AnsiString types are passed as parameters, the RawByteString version is called, and has to deal with possibly different encodings. The Delphi implementations simply ignore any encoding, so that the results are almost unusable :-(

In the AnsiStrings and StrUtils units another set of overloaded procedures is provided, for native AnsiString(CP_ACP) arguments. These versions are called only for all-native AnsiString arguments, so that no conversions are required.

Show quoted text 6 lines
1) RawByte ... any .. any -> supposedly no, supposedly keeping the encoding ID 2) not Raw ... Raw ... $FFFF (="RAW") -> ??? 3) not Raw ... same ... matching -> obviously No 4) not Raw ... same ... not matching (maybe $FFFF) -> this is an intersexual String what to do ?

[...]

Please note that the RawByteString type is not an intended type for variables, only for subroutine arguments. Strings of that type are either empty, with no encoding, or they hold the last assigned string, including its encoding.

DoDi

Reply by email

Felipe Monteiro de Carvalho
to Hans-Peter Diettrich: What else is the convention, whether e.g. "oe" should be combined into "?"? DoDi
Hans-Peter Diettrich wrote
What else is the convention, whether e.g. "oe" should be combined into "?"?

I am not 100% sure, but I think that this is *not* a valid Unicode example of decomposition.

Did you see the documentation that I passed before? You don't even have to read, just look at the picture. There you will see real decomposition:

http://unicode.org/reports/tr15/

Felipe Monteiro de Carvalho

Reply by email

Hans-Peter Diettrich
to Felipe Monteiro de Carvalho: On Fri, Oct 21, 2011 at 11:29 PM, Hans-Peter Diettrich !? Character decomposition is not…
Show quoted text 6 lines
On Fri, Oct 21, 2011 at 11:29 PM, Hans-Peter Diettrich wrote: > Right, that's one of the strange looking features of Unicode, related to > *language* conventions. !? Character decomposition is not at all language-related.

What else is the convention, whether e.g. "oe" should be combined into "?"?

DoDi

Reply by email

Michael Schnell
to Hans-Peter Diettrich: I'm not sure what you mean. Whenever a UnicodeString is passed as an argument, the…
Hans-Peter Diettrich wrote
Please note that the RawByteString type is not an intended type for variables, only for subroutine arguments.

I'm not speaking about wow anything is intended, but asking about a definition what the compiler is to do when these cases are detected at compile- and run-time.

If it is syntactically possible there needs to be a definition on what will happen.

-Michael

Reply by email

Ludo Brands
to Felipe Monteiro de Carvalho: On Mon, Oct 24, 2011 at 1:53 PM, Hans-Peter Diettrich I am not 100% sure, but I think…
Show quoted text 9 lines
On Mon, Oct 24, 2011 at 1:53 PM, Hans-Peter Diettrich wrote: > What else is the convention, whether e.g. "oe" should be combined into > "?"? I am not 100% sure, but I think that this is *not* a valid Unicode example of decomposition.

If "?" -> "oe" were a valid decomposition it would be in the following list http://www.unicode.org/charts/normalization/chart_Latin.html but it isn't.

Ludo

Reply by email

Michael Lutz
to Michael Schnell: Handling those in a computer program seems similar to having the computer understand a…
Michael Schnell wrote 5 lines
On 10/21/2011 01:26 PM, Michael Lutz wrote: > > Ever heard of decomposed characters? Handling those in a computer program seems similar to having the computer understand a philosophical text.

So I guess a user wanting to enter 'e?' in response to the prompt 'Please enter a single character' is clearly crazy? Even if that isn't a character in common natural languages, using it in a mathematical context for example isn't : The above character has *no* precomposed form (and is made up from two code points), and a program that stores the response to such a prompt into a single Char/WideChar/etc variable will just fail silently.

Michael Lutz

Reply by email

Mattias Gaertner
to Michael Lutz
Show quoted text 11 lines
Am 24.10.2011 12:15 schrieb Michael Schnell: > On 10/21/2011 01:26 PM, Michael Lutz wrote: >> >> Ever heard of decomposed characters? > Handling those in a computer program seems similar to having the > computer understand a philosophical text. So I guess a user wanting to enter 'e?' in response to the prompt 'Please enter a single character' is clearly crazy? Even if that isn't a character in common natural languages, using it in a mathematical context for example isn't mathematical context needs a prompt for a single character?

Mathematical papers often use symbols consisting of a 'single characters' with all kind of marks. There is no rule to use only one character per mathematical symbol.

Hint: The above character has *no* precomposed form (and is made up from two code points), and a program that stores the response to such a prompt into a single Char/WideChar/etc variable will just fail silently.

Yes.

Mattias

Reply by email

Žilvinas Ledas
to Felipe Monteiro de Carvalho: 2011/10/19 ?ilvinas Ledas : I am mostly interested in LowerCase / UpperCase. Could you…

Hi Felipe,

as I promised, I'm sending some tests. I am sending a file with your preferred format test cases (sorry, it is not a patch for testunicode.pas). Sorry, I didn't test them because I do not want to update from my current used revision...
I think for 1, 2 and 3 tests there will be no problems. Tests number 4 are interesting because some non composite upper case letters should be translated to composite symbols and vice versa.
But I should mention that only characters in test number 1 are used in everyday life. Other tests cases are for accented characters which are used in linguistic texts (eg. dictionaries).

Feel free to ask if you have any questions.

Regards,
?ilvinas Ledas

Felipe Monteiro de Carvalho wrote 23 lines
Hello, 2011/10/19 ?ilvinas Ledas: > I am native Lithuanian so I think can help at least providing info, but I > must understand what is the problem first. I am mostly interested in LowerCase / UpperCase. Could you explain how it works in Lithuanian and provide test cases for it? Test cases should be in this format: AssertStringOperationUTF8LowerCase('Unicode 0460 UTF8LowerCase', '', '????????????????', '????????????????'); Even better if they are in patches to the file lazarus/tests/lazutils/testunicode.pas First param is the label, the second the locale (in this case maybe something like 'lt', what is the ISO identifier for lituanian? Then UpperCase and then LowerCase. And try to make some tricky tests, to defeat partial implementations. 3 tests for lowercase and 3 for uppercase should be enough

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed... Name: lt_unicode_tests.pas
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20111026/4dd30fc0/attachment-0001.ksh>

Reply by email