Re: [Lazarus] String vs WideString

2017-08-18 Thread Ondrej Pokorny via Lazarus
On 16.08.2017 22:40, Sven Barth via Lazarus wrote: Trunk supports Insert() and Delete() on dynamic arrays, Concat() and + are on the near term ToDo list. I eagerly wait for these (and for anonymous methods) :) Ondrej -- ___ Lazarus mailing list Lazar

Re: [Lazarus] String vs WideString

2017-08-18 Thread Michael Schnell via Lazarus
On 18.08.2017 14:26, Sven Barth via Lazarus wrote: Delete(), Insert() and Pos() I understand those, and "+", etc, are in the pipe for Array of Byte, as well. I suppose workalikes for the most important TStrings siblings, such as TStringlist (including sort and LoadFromFile) be doable on to

Re: [Lazarus] String vs WideString

2017-08-18 Thread Sven Barth via Lazarus
Am 18.08.2017 10:42 schrieb "Michael Schnell via Lazarus" < lazarus@lists.lazarus-ide.org>: > > On 17.08.2017 11:27, Sven Barth via Lazarus wrote: >> >> >> Why do you want to stuff everything and the kitchen sink into TStrings? >> > To make use of the benefits the string type offers such as referen

Re: [Lazarus] String vs WideString

2017-08-18 Thread Martin Schreiber via Lazarus
On Friday 18 August 2017 13:02:44 Michael Schnell via Lazarus wrote: > On 18.08.2017 11:01, Graeme Geldenhuys via Lazarus wrote: > > On 2017-08-18 09:16, Tony Whyman via Lazarus wrote: > >> Damn, should remember never to copy and paste from Wikipedia! > > > > Or simply use "plain text" emails > > T

Re: [Lazarus] String vs WideString

2017-08-18 Thread Graeme Geldenhuys via Lazarus
On 2017-08-18 12:02, Michael Schnell wrote: To explain my mail above in plain Text: Nice. :-) And clever email clients will even "format" the plain text emails - looking much better than your original HTML version. See attached screenshot of how your last email looked like here. Regards,

Re: [Lazarus] String vs WideString

2017-08-18 Thread Michael Schnell via Lazarus
On 18.08.2017 11:01, Graeme Geldenhuys via Lazarus wrote: On 2017-08-18 09:16, Tony Whyman via Lazarus wrote: Damn, should remember never to copy and paste from Wikipedia! Or simply use "plain text" emails To explain my mail above in plain Text: A 32 bit Unicode needs two UTC-16 codes when

Re: [Lazarus] String vs WideString

2017-08-18 Thread Graeme Geldenhuys via Lazarus
On 2017-08-18 09:16, Tony Whyman via Lazarus wrote: Damn, should remember never to copy and paste from Wikipedia! Or simply use "plain text" emails to this mailing list. It reduces size considerably, and is still perfectly readable (like it has been for the last 30 years in email communicatio

Re: [Lazarus] String vs WideString

2017-08-18 Thread Michael Schnell via Lazarus
On 17.08.2017 11:27, Sven Barth via Lazarus wrote: Why do you want to stuff everything and the kitchen sink into TStrings? To make use of the benefits the string type offers such as reference counting and lazy copy. -Michael -- ___ Lazarus mailing

Re: [Lazarus] String vs WideString

2017-08-18 Thread Tony Whyman via Lazarus
Damn, should remember never to copy and paste from Wikipedia! On 17/08/17 13:40, Michael Schnell via Lazarus wrote: On 17.08.2017 12:41, Tony Whyman via Lazarus wrote: Finally: "In UTF-16, code points greater or equal to 2^16 are encoded using /two/ 16-bit code units. 2¹⁵ ??? -Michael -

Re: [Lazarus] String vs WideString

2017-08-17 Thread Graeme Geldenhuys via Lazarus
On 2017-08-17 17:59, Ondrej Pokorny via Lazarus wrote: change my code so I could get rid of the "variable not initialized" whenever you used FillChar(). And what do you use? I implemented a FillMem() function that calls FillChar(). The parameter are differently defined. Then changed my code

Re: [Lazarus] String vs WideString

2017-08-17 Thread Luca Olivetti via Lazarus
El 17/08/17 a les 01:34, Graeme Geldenhuys via Lazarus ha escrit: On 2017-08-16 19:26, Luca Olivetti via Lazarus wrote: I mean, TBytes is just an "array of char". NO! Char can now mean a 1-byte char or a 2-byte char (I don't know how Sorry, I meant "array of byte". The point is it doesn't

Re: [Lazarus] String vs WideString

2017-08-17 Thread Ondrej Pokorny via Lazarus
On 17.08.2017 16:34, Graeme Geldenhuys via Lazarus wrote: On 2017-08-17 13:40, Marcos Douglas B. Santos via Lazarus wrote: Sorry, but every single warning is a... warning... that needs to be resolved. I feel exactly the same. :-) It took me ages to figure out how to change my code so I coul

Re: [Lazarus] String vs WideString

2017-08-17 Thread wkitty42--- via Lazarus
On 08/17/2017 01:10 AM, Sven Barth via Lazarus wrote: Am 17.08.2017 04:16 schrieb "wkitty42--- via Lazarus" > On 08/16/2017 06:46 PM, Luca Olivetti via Lazarus wrote: >> I started using strings as communication buffers since delphi 2. There >> weren't even dynamic arrays then... > > really?

Re: [Lazarus] String vs WideString

2017-08-17 Thread Graeme Geldenhuys via Lazarus
On 2017-08-17 13:40, Marcos Douglas B. Santos via Lazarus wrote: Sorry, but every single warning is a... warning... that needs to be resolved. I feel exactly the same. :-) It took me ages to figure out how to change my code so I could get rid of the "variable not initialized" whenever you u

Re: [Lazarus] String vs WideString

2017-08-17 Thread Martin Schreiber via Lazarus
On Thursday 17 August 2017 12:09:02 Bart via Lazarus wrote: > On 8/17/17, Luca Olivetti via Lazarus wrote: > > I started using strings as communication buffers since delphi 2. There > > weren't even dynamic arrays then... > > From the Turbo Pascal Help: > > "A string type variable is a sequence of

Re: [Lazarus] String vs WideString

2017-08-17 Thread Sven Barth via Lazarus
Am 17.08.2017 12:17 schrieb "Bart via Lazarus" < lazarus@lists.lazarus-ide.org>: > > On 8/17/17, Sven Barth via Lazarus wrote: > > >> really? delphi came from TP/BP... i was (still am, actually) using > > dynamic arrays in TP6 ;) > > > > Dynamic arrays in the form of "array of Type" were only intr

Re: [Lazarus] String vs WideString

2017-08-17 Thread Sven Barth via Lazarus
Am 17.08.2017 14:32 schrieb "Michael Schnell via Lazarus" < lazarus@lists.lazarus-ide.org>: > > On 17.08.2017 12:09, Bart via Lazarus wrote: >> >> >> Variables of the ordinal type Char are used to store ASCII characters." >> >> > According to this wording, using Windows with ANSI character set woul

Re: [Lazarus] String vs WideString

2017-08-17 Thread Marcos Douglas B. Santos via Lazarus
On Wed, Aug 16, 2017 at 12:38 PM, Juha Manninen via Lazarus wrote: > On Wed, Aug 16, 2017 at 5:48 PM, Marcos Douglas B. Santos via Lazarus >> Are you saying that I need to do this? >> (following the firt example on this thread) > > No, if the parameter is WideString, not a pointer PWideChar, you c

Re: [Lazarus] String vs WideString

2017-08-17 Thread Michael Schnell via Lazarus
On 17.08.2017 12:41, Tony Whyman via Lazarus wrote: Finally: "In UTF-16, code points greater or equal to 2^16 are encoded using /two/ 16-bit code units. 2¹⁵ ??? -Michael-- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-i

Re: [Lazarus] String vs WideString

2017-08-17 Thread Michael Schnell via Lazarus
On 17.08.2017 12:41, Tony Whyman via Lazarus wrote: UCS-2 differs from UTF-16 by being a constant length encoding and only capable of encoding characters of BMP, it is supported by many programs." Rather obviously Embarcadero primarily had UCS-2 in mind as they created the "Unicode aware" De

Re: [Lazarus] String vs WideString

2017-08-17 Thread Michael Schnell via Lazarus
On 17.08.2017 12:09, Bart via Lazarus wrote: Variables of the ordinal type Char are used to store ASCII characters." According to this wording, using Windows with ANSI character set would be a no-go. -Michael -- ___ Lazarus mailing list Lazarus@l

Re: [Lazarus] String vs WideString

2017-08-17 Thread Tony Whyman via Lazarus
On 16/08/17 11:05, Juha Manninen via Lazarus wrote: 2. Clean up the char type. ... Why shouldn't there be a single char type that intuitively represents a single character regardless of how many bytes are used to represent it. What do you mean by "a single character"? A "character" in Unicode c

Re: [Lazarus] String vs WideString

2017-08-17 Thread Tony Whyman via Lazarus
On 16/08/17 11:05, Juha Manninen via Lazarus wrote: On Mon, Aug 14, 2017 at 4:21 PM, Tony Whyman via Lazarus wrote: UTF-16/Unicode can only store 65,536 characters while the Unicode standard (that covers UTF8 as well) defines 136,755 characters. UTF-16/Unicode's main advantage seems to be for r

Re: [Lazarus] String vs WideString

2017-08-17 Thread Bart via Lazarus
On 8/17/17, Sven Barth via Lazarus wrote: >> really? delphi came from TP/BP... i was (still am, actually) using > dynamic arrays in TP6 ;) > > Dynamic arrays in the form of "array of Type" were only introduced in > Delphi 3 if I remember correctly. Anything before that needed manual memory > mana

Re: [Lazarus] String vs WideString

2017-08-17 Thread Bart via Lazarus
On 8/17/17, Luca Olivetti via Lazarus wrote: > I started using strings as communication buffers since delphi 2. There > weren't even dynamic arrays then... From the Turbo Pascal Help: "A string type variable is a sequence of characters ..." And then when you click on "characters": "Char type

Re: [Lazarus] String vs WideString

2017-08-17 Thread Sven Barth via Lazarus
Am 17.08.2017 11:21 schrieb "Michael Schnell via Lazarus" < lazarus@lists.lazarus-ide.org>: > > On 16.08.2017 22:40, Sven Barth via Lazarus wrote: >> >> Trunk supports Insert() and Delete() on dynamic arrays, Concat() and + are on the near term ToDo list. > > > Supposedly "pos", as well. But that d

Re: [Lazarus] String vs WideString

2017-08-17 Thread Michael Schnell via Lazarus
On 16.08.2017 22:40, Sven Barth via Lazarus wrote: Trunk supports Insert() and Delete() on dynamic arrays, Concat() and + are on the near term ToDo list. Supposedly "pos", as well. But that does not really help if we don't have a TStringList workalike, and supposedly several more library func

Re: [Lazarus] String vs WideString

2017-08-17 Thread Michael Schnell via Lazarus
On 16.08.2017 20:26, Luca Olivetti via Lazarus wrote: Call me lazy but I don't want to reinvent the wheel and re-implement from scratch the functionality that a plain ansistring provides and TBytes to this day doesn't. So please continue in the thread "dynamic string proposal". Exactly this

Re: [Lazarus] String vs WideString

2017-08-16 Thread Sven Barth via Lazarus
Am 17.08.2017 04:16 schrieb "wkitty42--- via Lazarus" < lazarus@lists.lazarus-ide.org>: > > On 08/16/2017 06:46 PM, Luca Olivetti via Lazarus wrote: >> >> I started using strings as communication buffers since delphi 2. There >> weren't even dynamic arrays then... > > > really? delphi came from TP/

Re: [Lazarus] String vs WideString

2017-08-16 Thread wkitty42--- via Lazarus
On 08/16/2017 06:46 PM, Luca Olivetti via Lazarus wrote: I started using strings as communication buffers since delphi 2. There weren't even dynamic arrays then... really? delphi came from TP/BP... i was (still am, actually) using dynamic arrays in TP6 ;) -- NOTE: No off-list assistance is

Re: [Lazarus] String vs WideString

2017-08-16 Thread wkitty42--- via Lazarus
On 08/16/2017 07:30 PM, Graeme Geldenhuys via Lazarus wrote: On 2017-08-16 18:35, Sven Barth via Lazarus wrote: You are wrong. The string types in 3.0.x and 3.1 are like this: Thanks for correcting me. I was thinking of the "$modeswitch unicodestring" option. will that modeswitch take care

Re: [Lazarus] String vs WideString

2017-08-16 Thread Graeme Geldenhuys via Lazarus
On 2017-08-16 23:46, Luca Olivetti via Lazarus wrote: I started using strings as communication buffers since delphi 2. There weren't even dynamic arrays then... Well, Link-Lists existed from the beginning of time. I used them plenty in my TP days, and adding, inserting, indexing etc was pretty

Re: [Lazarus] String vs WideString

2017-08-16 Thread Graeme Geldenhuys via Lazarus
On 2017-08-16 19:26, Luca Olivetti via Lazarus wrote: I mean, TBytes is just an "array of char". NO! Char can now mean a 1-byte char or a 2-byte char (I don't know how FPC plans to support Unicode surrogate pairs which will require 4-bytes). In the olden days (Delphi 7 and FPC 2.6.4) the Cha

Re: [Lazarus] String vs WideString

2017-08-16 Thread Graeme Geldenhuys via Lazarus
On 2017-08-16 18:35, Sven Barth via Lazarus wrote: You are wrong. The string types in 3.0.x and 3.1 are like this: Thanks for correcting me. I was thinking of the "$modeswitch unicodestring" option. Regards, Graeme -- ___ Lazarus mailing list La

Re: [Lazarus] String vs WideString

2017-08-16 Thread Luca Olivetti via Lazarus
El 16/08/17 a les 22:40, Sven Barth via Lazarus ha escrit: On 16.08.2017 20:26, Luca Olivetti via Lazarus wrote: El 16/08/17 a les 01:17, Graeme Geldenhuys via Lazarus ha escrit: In hind sight, using TBytes or TMemoryStream and it would have been very clear that it is a storage container for b

Re: [Lazarus] String vs WideString

2017-08-16 Thread Sven Barth via Lazarus
On 16.08.2017 20:26, Luca Olivetti via Lazarus wrote: > El 16/08/17 a les 01:17, Graeme Geldenhuys via Lazarus ha escrit: > >> In hind sight, using TBytes or TMemoryStream and it would have been >> very clear that it is a storage container for byte sized data, and no >> automatic conversion (by th

Re: [Lazarus] String vs WideString

2017-08-16 Thread Luca Olivetti via Lazarus
El 16/08/17 a les 20:26, Luca Olivetti via Lazarus ha escrit: El 16/08/17 a les 01:17, Graeme Geldenhuys via Lazarus ha escrit: In hind sight, using TBytes or TMemoryStream and it would have been very clear that it is a storage container for byte sized data, and no automatic conversion (by the

Re: [Lazarus] String vs WideString

2017-08-16 Thread Luca Olivetti via Lazarus
El 16/08/17 a les 01:17, Graeme Geldenhuys via Lazarus ha escrit: In hind sight, using TBytes or TMemoryStream and it would have been very clear that it is a storage container for byte sized data, and no automatic conversion (by the compiler) would be done to data stored in such containers.

Re: [Lazarus] String vs WideString

2017-08-16 Thread Sven Barth via Lazarus
On 16.08.2017 11:08, Graeme Geldenhuys via Lazarus wrote: > On 2017-08-16 09:43, Michael Schnell via Lazarus wrote: >> IMHO, any implementation of TStrings that forces a conversion (just >> because the class uses TStrings and not due to a logical demand), is a >> contradiction to providing code awa

Re: [Lazarus] String vs WideString

2017-08-16 Thread Sven Barth via Lazarus
On 15.08.2017 10:34, Tony Whyman via Lazarus wrote: > On 14/08/17 17:47, Sven Barth via Lazarus wrote: >> The main problem of such a dynamic type would be the inability to do >> fast indexing as the compiler would need to insert runtime checks for >> the size of a character. I had already thought t

Re: [Lazarus] String vs WideString

2017-08-16 Thread Juha Manninen via Lazarus
On Wed, Aug 16, 2017 at 5:48 PM, Marcos Douglas B. Santos via Lazarus wrote: > I cannot say from others, but I had this issue (about WideString) for now. The section "Calling Windows API" says: 'Only the "W" versions of Windows API functions should be called. It is like in Delphi except that you

Re: [Lazarus] String vs WideString

2017-08-16 Thread Marcos Douglas B. Santos via Lazarus
On Wed, Aug 16, 2017 at 11:37 AM, Juha Manninen via Lazarus wrote: > On Wed, Aug 16, 2017 at 5:13 PM, Marcos Douglas B. Santos via Lazarus > wrote: >> Thanks. I know about this page... unfortunately looks like it is not >> enough, since many others still complain. > > What is missing? I can try t

Re: [Lazarus] String vs WideString

2017-08-16 Thread Juha Manninen via Lazarus
On Wed, Aug 16, 2017 at 5:13 PM, Marcos Douglas B. Santos via Lazarus wrote: > Thanks. I know about this page... unfortunately looks like it is not > enough, since many others still complain. What is missing? I can try to improve it. > This thread is not only about WinAPI. I have this problem be

Re: [Lazarus] String vs WideString

2017-08-16 Thread Marcos Douglas B. Santos via Lazarus
On Wed, Aug 16, 2017 at 6:12 AM, Juha Manninen via Lazarus wrote: > On Mon, Aug 14, 2017 at 4:11 PM, Marcos Douglas B. Santos via Lazarus > wrote: >> Unicode everywhere and you using AnsiString and doing everything... >> Now I'm confused. > > Yes, please read: > http://wiki.freepascal.org/Unicod

Re: [Lazarus] String vs WideString

2017-08-16 Thread Graeme Geldenhuys via Lazarus
On 2017-08-16 11:05, Juha Manninen via Lazarus wrote: Unfortunately many other programmers had the same wrong idea or they were just lazy. The result anyway is a lot of broken UTF-16 code out there. Yeah, I see that even in commercial products and projects. It's very sad to see. Hence I always

Re: [Lazarus] String vs WideString

2017-08-16 Thread Michael Schnell via Lazarus
On 16.08.2017 12:22, Juha Manninen via Lazarus wrote: You should stop writing in this thread now. I agree with Mattias. I perfectly agree with you. But you can't blame me for answering when asked. -Michael -- ___ Lazarus mailing list Lazarus@lists.l

Re: [Lazarus] String vs WideString

2017-08-16 Thread Juha Manninen via Lazarus
On Wed, Aug 16, 2017 at 12:12 PM, Michael Schnell via Lazarus wrote: > UTF-8 and UTF-16 are just encoding variants for 32 bit Unicode "characters", > storing them in n (or 2*n) Bytes according to a simple scheme. No, they are encodings for codepoints, not "characters" (whatever that means). Mich

Re: [Lazarus] String vs WideString

2017-08-16 Thread Michael Schnell via Lazarus
On 16.08.2017 11:55, Mattias Gaertner via Lazarus wrote: 1,114,112 possible code points need at most 21 bits. Due to encoding at most 32bit. Sorry. Typo. -Michael -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/

Re: [Lazarus] String vs WideString

2017-08-16 Thread Juha Manninen via Lazarus
On Mon, Aug 14, 2017 at 4:21 PM, Tony Whyman via Lazarus wrote: > UTF-16/Unicode can only store 65,536 characters while the Unicode standard > (that covers UTF8 as well) defines 136,755 characters. > UTF-16/Unicode's main advantage seems to be for rapid indexing of large > strings. That shows com

Re: [Lazarus] String vs WideString

2017-08-16 Thread Mattias Gaertner via Lazarus
On Wed, 16 Aug 2017 11:33:04 +0200 Michael Schnell via Lazarus wrote: >[...] > But in fact "Unicode" is just a universal standard defining 64 bit > entities. No. 1,114,112 possible code points need at most 21 bits. Due to encoding at most 32bit. Mattias -- ___

Re: [Lazarus] String vs WideString

2017-08-16 Thread Michael Schnell via Lazarus
On 16.08.2017 11:32, Mattias Gaertner via Lazarus wrote: Anyone who wants to discuss the grand picture of strings in FPC for the millionth time should start a new topic. Right you are. And it will be by far too late and futile, anyway, because of the reasons discussed a million times. -Michae

Re: [Lazarus] String vs WideString

2017-08-16 Thread Michael Schnell via Lazarus
On 16.08.2017 11:08, Graeme Geldenhuys via Lazarus wrote: Are you suggesting that internally TStrings should have different storage for all possible languages, Not at all. In the said paper I point out that a new fully dynamical string encoding brand would be introduced and same is used for TStr

Re: [Lazarus] String vs WideString

2017-08-16 Thread Michael Schnell via Lazarus
On 16.08.2017 11:08, Graeme Geldenhuys via Lazarus wrote: So it makes sense that TStrings should use UnicodeString internally to store its data. The Unicode standard is also the only standard that can support any language. But in fact "Unicode" is just a universal standard defining 64 bit enti

Re: [Lazarus] String vs WideString

2017-08-16 Thread Mattias Gaertner via Lazarus
On Wed, 16 Aug 2017 11:09:17 +0200 Michael Schnell via Lazarus wrote: > On 16.08.2017 10:58, Mattias Gaertner via Lazarus wrote: > > This thread is going out of topic. > > Please start a new thread if you want to discuss Delphi strings. > You can't discuss fpc's string problems without mentioni

Re: [Lazarus] String vs WideString

2017-08-16 Thread Michael Schnell via Lazarus
On 15.08.2017 18:33, Mattias Gaertner via Lazarus wrote: Do you propose a string without the array operator [] ? I don't understand what you mean by this. Of course an appropriate "char" type for each string encoding brand could to be provided, hence a "CP_QWord Char" as an alias or a QWord.

Re: [Lazarus] String vs WideString

2017-08-16 Thread Juha Manninen via Lazarus
On Mon, Aug 14, 2017 at 4:11 PM, Marcos Douglas B. Santos via Lazarus wrote: > Unicode everywhere and you using AnsiString and doing everything... > Now I'm confused. Yes, please read: http://wiki.freepascal.org/Unicode_Support_in_Lazarus I have advertised it so much that some people are already

Re: [Lazarus] String vs WideString

2017-08-16 Thread Michael Schnell via Lazarus
On 15.08.2017 19:53, wkitty42--- via Lazarus wrote: what if 3 and 4 byte characters are required? will they also work in UnicodeStrings? UTF-8 and UTF-16 are just encoding variants for 32 bit Unicode "characters", storing them in n (or 2*n) Bytes according to a simple scheme. -Michael -- ___

Re: [Lazarus] String vs WideString

2017-08-16 Thread Michael Schnell via Lazarus
On 16.08.2017 10:58, Mattias Gaertner via Lazarus wrote: This thread is going out of topic. Please start a new thread if you want to discuss Delphi strings. You can't discuss fpc's string problems without mentioning Delphi, as they are a direct consequence as well of Delphi-compatibility as of

Re: [Lazarus] String vs WideString

2017-08-16 Thread Graeme Geldenhuys via Lazarus
On 2017-08-16 09:43, Michael Schnell via Lazarus wrote: IMHO, any implementation of TStrings that forces a conversion (just because the class uses TStrings and not due to a logical demand), is a contradiction to providing code aware strings at all. But in FPC 3.x (using modern compiler modes -

Re: [Lazarus] String vs WideString

2017-08-16 Thread Michael Van Canneyt via Lazarus
On Wed, 16 Aug 2017, Michael Schnell via Lazarus wrote: On 15.08.2017 22:45, Graeme Geldenhuys via Lazarus wrote: How is that not "abuse"??? IMHO it's a major shortcoming to define "string" as "printable text". On the contrary. That is exactly what it means. Anything else is just a colle

Re: [Lazarus] String vs WideString

2017-08-16 Thread Michael Schnell via Lazarus
On 15.08.2017 22:45, Graeme Geldenhuys via Lazarus wrote: How is that not "abuse"??? IMHO it's a major shortcoming to define "string" as "printable text". In fact the name "String" does not suggest this at all. A "string" in my understanding just is a sequence of similar "things". A string

Re: [Lazarus] String vs WideString

2017-08-16 Thread Juha Manninen via Lazarus
On Wed, Aug 16, 2017 at 8:53 AM, Bo Berglund via Lazarus wrote: > Based on this experience I wanted to alert the OP of the fact that > using AnsiString instead of string is not a cure-all for binary data, > you need to fix the codepage too, which is what the RawByteString does > for you Bo, e

Re: [Lazarus] String vs WideString

2017-08-16 Thread Mattias Gaertner via Lazarus
On Wed, 16 Aug 2017 10:47:37 +0200 Michael Schnell via Lazarus wrote: > On 15.08.2017 19:29, Luca Olivetti via Lazarus wrote: > > I has worked extremely well and reliably until fpc 2.6.4 (i.e. with > > string=ansistring). > > Does it not work in 3.x? > I understand that storing uncoded Bytes i

Re: [Lazarus] String vs WideString

2017-08-16 Thread Michael Schnell via Lazarus
On 15.08.2017 21:38, Ondrej Pokorny via Lazarus wrote: Furthermore, if you use(d) strings for binary data, just replace old string for AnsiString/RawByteString (and Char for AnsiChar, PChar for PAnsiChar) and you are good to go. Annoying but no big deal. This only works if all tools that you u

Re: [Lazarus] String vs WideString

2017-08-16 Thread Michael Schnell via Lazarus
On 15.08.2017 19:29, Luca Olivetti via Lazarus wrote: I has worked extremely well and reliably until fpc 2.6.4 (i.e. with string=ansistring). Does it not work in 3.x? I understand that storing uncoded Bytes in UTF8-Strings (hence in fpc) works as good as it always had, as long as all strings ar

Re: [Lazarus] String vs WideString

2017-08-16 Thread Michael Schnell via Lazarus
On 15.08.2017 19:18, Graeme Geldenhuys via Lazarus wrote: Why can't that be changed to a UnicodeString or UTF8String IMHO, any implementation of TStrings that forces a conversion (just because the class uses TStrings and not due to a logical demand), is a contradiction to providing code awar

Re: [Lazarus] String vs WideString

2017-08-15 Thread Bo Berglund via Lazarus
On Wed, 16 Aug 2017 07:53:11 +0200, Bo Berglund via Lazarus wrote: >But I have now moved on and replaced all comm related containers with >TBytes including modifying the serial component we have used. >(With some help from Remy Lebeau). I forgot to mention that the problem area is located inside

Re: [Lazarus] String vs WideString

2017-08-15 Thread Bo Berglund via Lazarus
On Tue, 15 Aug 2017 21:22:10 +0200, Luca Olivetti via Lazarus wrote: >(I remarked the "if" because I don't know if that's the case, according >to Bo Berglund's experience it is) Just to expand on my "experience" and the reason I posted: My work on converting the old program started back a coup

Re: [Lazarus] String vs WideString

2017-08-15 Thread Graeme Geldenhuys via Lazarus
On 2017-08-15 23:41, Luca Olivetti via Lazarus wrote: A "string" was just a handy container for bytes so I think it was the right choice for storing, er, bytes. The type "String" has always been an alias to another type, and could mean many things. eg: ShortString, AnsiString, and now Unicode

Re: [Lazarus] String vs WideString

2017-08-15 Thread Luca Olivetti via Lazarus
El 15/08/17 a les 22:45, Graeme Geldenhuys via Lazarus ha escrit: On 2017-08-15 20:22, Luca Olivetti via Lazarus wrote: Wait a minute, why "abuse"? After all, before code aware strings, an ansistring could store any kind of arbitrary data with no problem and no conversion, and made it extremely

Re: [Lazarus] String vs WideString

2017-08-15 Thread Graeme Geldenhuys via Lazarus
On 2017-08-15 20:22, Luca Olivetti via Lazarus wrote: Wait a minute, why "abuse"? After all, before code aware strings, an ansistring could store any kind of arbitrary data with no problem and no conversion, and made it extremely easy Just listen to what you are saying A string type and yo

Re: [Lazarus] String vs WideString

2017-08-15 Thread Luca Olivetti via Lazarus
El 15/08/17 a les 22:08, Luca Olivetti ha escrit: El 15/08/17 a les 21:38, Ondrej Pokorny via Lazarus ha escrit: On 15.08.2017 21:34, Mattias Gaertner via Lazarus wrote: On Tue, 15 Aug 2017 21:22:10 +0200 Luca Olivetti via Lazarus wrote: [...] *If* code that worked before (and dare I say wit

Re: [Lazarus] String vs WideString

2017-08-15 Thread Luca Olivetti via Lazarus
El 15/08/17 a les 21:38, Ondrej Pokorny via Lazarus ha escrit: On 15.08.2017 21:34, Mattias Gaertner via Lazarus wrote: On Tue, 15 Aug 2017 21:22:10 +0200 Luca Olivetti via Lazarus wrote: [...] *If* code that worked before (and dare I say without abusing the language) suddenly breaks, the bug

Re: [Lazarus] String vs WideString

2017-08-15 Thread Luca Olivetti via Lazarus
El 15/08/17 a les 21:38, Ondrej Pokorny via Lazarus ha escrit: On 15.08.2017 21:34, Mattias Gaertner via Lazarus wrote: On Tue, 15 Aug 2017 21:22:10 +0200 Luca Olivetti via Lazarus wrote: [...] *If* code that worked before (and dare I say without abusing the language) suddenly breaks, the bug

Re: [Lazarus] String vs WideString

2017-08-15 Thread Ondrej Pokorny via Lazarus
On 15.08.2017 21:34, Mattias Gaertner via Lazarus wrote: On Tue, 15 Aug 2017 21:22:10 +0200 Luca Olivetti via Lazarus wrote: [...] *If* code that worked before (and dare I say without abusing the language) suddenly breaks, the bug is in the compiler and not in the library. ... unless of cours

Re: [Lazarus] String vs WideString

2017-08-15 Thread Mattias Gaertner via Lazarus
On Tue, 15 Aug 2017 21:22:10 +0200 Luca Olivetti via Lazarus wrote: >[...] > *If* code that worked before (and dare I say without abusing the > language) suddenly breaks, the bug is in the compiler and not in the > library. ... unless of course the incompatibility is deliberate and documented.

Re: [Lazarus] String vs WideString

2017-08-15 Thread Luca Olivetti via Lazarus
El 15/08/17 a les 21:14, Graeme Geldenhuys via Lazarus ha escrit: On 2017-08-15 18:29, Luca Olivetti via Lazarus wrote: but for 3rd party libraries/components (e.g. synapse comes to mind Then better start filing bug reports to all those 3rd party libraries and components - they have been abus

Re: [Lazarus] String vs WideString

2017-08-15 Thread Graeme Geldenhuys via Lazarus
On 2017-08-15 18:29, Luca Olivetti via Lazarus wrote: but for 3rd party libraries/components (e.g. synapse comes to mind Then better start filing bug reports to all those 3rd party libraries and components - they have been abusing the system and will silently fail. Not to mention that FPC is

Re: [Lazarus] String vs WideString

2017-08-15 Thread wkitty42--- via Lazarus
On 08/15/2017 05:25 AM, Michael Van Canneyt via Lazarus wrote: As it is now, FPC offers a way out for all cases: WideString/UnicodeString for those that want 2-byte characters. what if 3 and 4 byte characters are required? will they also work in UnicodeStrings? i'm looking at this from a li

Re: [Lazarus] String vs WideString

2017-08-15 Thread Luca Olivetti via Lazarus
El 15/08/17 a les 11:25, Michael Van Canneyt via Lazarus ha escrit: Attempting to store binary data in a string is not advisable. Dynamic arrays, TBytes and - in the worst case - TBytesStream are powerful enough to cover most use-cases in this area. I has worked extremely well and reliably

Re: [Lazarus] String vs WideString

2017-08-15 Thread Graeme Geldenhuys via Lazarus
On 2017-08-15 10:52, Michael Van Canneyt via Lazarus wrote: The only 'problem' is that TStrings uses a single-byte string. Why can't that be changed to a UnicodeString or UTF8String - after all, the Unicode standard is meant to support all languages. I would have thought that would be an obvi

Re: [Lazarus] String vs WideString

2017-08-15 Thread Mattias Gaertner via Lazarus
On Tue, 15 Aug 2017 16:44:30 +0200 Michael Schnell via Lazarus wrote: > On 15.08.2017 14:53, Mattias Gaertner via Lazarus wrote: > > Do you mean a 'char' is a string in your proposal? > Nope. In my proposal there would be Chars for any statically encoded > String Type, hence 1, 2, 4, and 8 by

Re: [Lazarus] String vs WideString

2017-08-15 Thread Michael Schnell via Lazarus
On 15.08.2017 14:53, Mattias Gaertner via Lazarus wrote: Do you mean a 'char' is a string in your proposal? Nope. In my proposal there would be Chars for any statically encoded String Type, hence 1, 2, 4, and 8 byte wide. (As regarding statically encoded string (and char) brands, it's just an e

Re: [Lazarus] String vs WideString

2017-08-15 Thread Michael Van Canneyt via Lazarus
On Tue, 15 Aug 2017, Mattias Gaertner via Lazarus wrote: On Tue, 15 Aug 2017 14:26:34 +0200 Michael Schnell via Lazarus wrote: On 15.08.2017 11:15, Tony Whyman via Lazarus wrote: > Why shouldn't there be a single char type that intuitively represents > a single character regardless of how

Re: [Lazarus] String vs WideString

2017-08-15 Thread Mattias Gaertner via Lazarus
On Tue, 15 Aug 2017 14:26:34 +0200 Michael Schnell via Lazarus wrote: > On 15.08.2017 11:15, Tony Whyman via Lazarus wrote: > > Why shouldn't there be a single char type that intuitively represents > > a single character regardless of how many bytes are used to represent it. > > I suppose by

Re: [Lazarus] String vs WideString

2017-08-15 Thread Michael Schnell via Lazarus
On 15.08.2017 11:15, Tony Whyman via Lazarus wrote: 3. The problem with string handling today is that it is not based on a consistent approach to the character type. If you clean up character handling then the model for string handling should become obvious. A string is after all no m

Re: [Lazarus] String vs WideString

2017-08-15 Thread Michael Schnell via Lazarus
On 15.08.2017 11:15, Tony Whyman via Lazarus wrote: Why shouldn't there be a single char type that intuitively represents a single character regardless of how many bytes are used to represent it. I suppose by "char" you mean "single printable thingy" with Unicode it's rather debatable what suc

Re: [Lazarus] String vs WideString

2017-08-15 Thread Bart via Lazarus
On 8/15/17, Tony Whyman via Lazarus wrote: > 2. Clean up the char type. > > Why shouldn't there be a single char > type that intuitively represents a single character regardless of > how many bytes are used to represent it. You would have to define what "a single character" means in

Re: [Lazarus] String vs WideString

2017-08-15 Thread Michael Van Canneyt via Lazarus
On Tue, 15 Aug 2017, Michael Schnell via Lazarus wrote: On 15.08.2017 12:15, Michael Van Canneyt via Lazarus wrote: What does S[2] mean in your proposal ? Is it 1, 2, 4 or even 8 bytes ? Regarding the users' appreciation, the S[x] notation is decently incompatible between the different strin

Re: [Lazarus] String vs WideString

2017-08-15 Thread Michael Schnell via Lazarus
On 15.08.2017 12:15, Michael Van Canneyt via Lazarus wrote: What does S[2] mean in your proposal ? Is it 1, 2, 4 or even 8 bytes ? Regarding the users' appreciation, the S[x] notation is decently incompatible between the different string types and compiler versions. There were hundreds of comp

Re: [Lazarus] String vs WideString

2017-08-15 Thread Michael Schnell via Lazarus
On 15.08.2017 12:11, Mattias Gaertner via Lazarus wrote: It does not explain what the characters of DynamicString are, does it? I don't understand what you are asking. The element size and encoding of a Dynamic String ("CP_ANY" in the document) are not predefined, but depend on the content:

Re: [Lazarus] String vs WideString

2017-08-15 Thread Michael Van Canneyt via Lazarus
On Tue, 15 Aug 2017, Mattias Gaertner via Lazarus wrote: On Tue, 15 Aug 2017 12:02:28 +0200 Michael Schnell via Lazarus wrote: On 15.08.2017 11:52, Michael Van Canneyt via Lazarus wrote: > This cannot be solved properly except by duplicating the classes unit. Sorry to disagree, but IMHO t

Re: [Lazarus] String vs WideString

2017-08-15 Thread Mattias Gaertner via Lazarus
On Tue, 15 Aug 2017 12:02:28 +0200 Michael Schnell via Lazarus wrote: > On 15.08.2017 11:52, Michael Van Canneyt via Lazarus wrote: > > This cannot be solved properly except by duplicating the classes unit. > > Sorry to disagree, but IMHO this can only be solved properly by defining > an addi

Re: [Lazarus] String vs WideString

2017-08-15 Thread Michael Schnell via Lazarus
On 15.08.2017 11:52, Michael Van Canneyt via Lazarus wrote: This cannot be solved properly except by duplicating the classes unit. Sorry to disagree, but IMHO this can only be solved properly by defining an additional fully dynamically encoded string type and use same for TStrings (see -> ht

Re: [Lazarus] String vs WideString

2017-08-15 Thread Michael Schnell via Lazarus
On 15.08.2017 11:15, Tony Whyman via Lazarus wrote: In this case, I would argue that both are true. And the culprit obviously is Embarcadeo and not the fpc or the Lazarus team, who did their best to try to do a compatible and implementation that is really workable on the multiple supported pla

Re: [Lazarus] String vs WideString

2017-08-15 Thread Michael Van Canneyt via Lazarus
On Tue, 15 Aug 2017, Michael Schnell via Lazarus wrote: On 15.08.2017 11:25, Michael Van Canneyt via Lazarus wrote: WideString/UnicodeString for those that want 2-byte characters. A codepage-aware single-byte string for those that want 1-byte characters. The shortstring is even still availa

Re: [Lazarus] String vs WideString

2017-08-15 Thread Michael Schnell via Lazarus
On 15.08.2017 11:25, Michael Van Canneyt via Lazarus wrote: WideString/UnicodeString for those that want 2-byte characters. A codepage-aware single-byte string for those that want 1-byte characters. The shortstring is even still available. IM (often stated) O, this does not help as long as TS

Re: [Lazarus] String vs WideString

2017-08-15 Thread Michael Van Canneyt via Lazarus
On Tue, 15 Aug 2017, Mattias Gaertner via Lazarus wrote: On Mon, 14 Aug 2017 18:47:58 +0200 Sven Barth via Lazarus wrote: [...] The main problem of such a dynamic type would be the inability to do fast indexing as the compiler would need to insert runtime checks for the size of a character.

Re: [Lazarus] String vs WideString

2017-08-15 Thread Tony Whyman via Lazarus
You can me as a "like" on that one. On 15/08/17 10:13, Mattias Gaertner via Lazarus wrote: IMHO the main problem of adding a new string type is https://xkcd.com/927/ -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org https://lists.lazarus-ide

Re: [Lazarus] String vs WideString

2017-08-15 Thread Tony Whyman via Lazarus
On 14/08/17 22:01, Juha Manninen via Lazarus wrote: Tony Whyman, this issue has been discussed again and again for the past 10+ years first in FPC mailing lists and then in Lazarus lists. The current Unicode support in Lazarus works f***ing well and is amazingly compatible with Delphi. WinAPI par

  1   2   >