Re: [fpc-pascal] String concatenation failure (again)

2016-08-03 Thread Jürgen Hestermann

Am 2016-08-02 um 20:12 schrieb José Mejuto:
> Check the length of the string I think you have a NULL char at the end of 
every string, so only the first one (up to #00 char) is displayed.

Yes, you are right.
When I change the code


for i := Low(Liste) to High(Liste) do
   S := S+Liste[i]+LineEnding;


to


for i := Low(Liste) to High(Liste) do
   S := S+pchar(Liste[i])+LineEnding;


then it works okay.
The Win-API call retrieves the ending null byte too
so it ends up in my array of strings.

Strange is that it already worked with FPC 2.x.
Of course I had to convert UTF16 to UTF8 manually
but I don't have the old code anymore.
It could be that I had to use pchar in that case too which
would explain why it worked before (I then removed
"unneccessary" convertion routines and it seems
I removed the pchar calls too).

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] String concatenation failure (again)

2016-08-02 Thread José Mejuto

El 02/08/2016 a las 16:51, Jürgen Hestermann escribió:


I would expect that with the new string encoding handling
widestring will be converted automatically to "MyStringType"
(which is string in my case). This assumption is  encouraged
by the fact that "Liste" is shown with the correct list of all strings
in the evaluate window when debugging.

The interesting thing is, that *one* (the first) string
from "Liste" is added to "S" (but all others are missing).


Hello,

Check the length of the string I think you have a NULL char at the end 
of every string, so only the first one (up to #00 char) is displayed.



--

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] String concatenation failure (again)

2016-08-02 Thread Jürgen Hestermann

Am 2016-08-02 um 12:25 schrieb Jürgen Hestermann:
> --
> type MyStringType = string;
> var S : MyStringType;
> Liste : array of MyStringType;
> i : SizeInt;
>
> begin
> [..] // "Liste" is setup with many string entries (which are also shown 
correctly with Ctrl+F7 (evaluate/modify)
> S := '';
> for i := Low(Liste) to High(Liste) do
>S := S+Liste[i]+LineEnding;
> SetLength(Liste,0);
> ShowMessage(S);
> end;
> --

I just tested a bit more and it seems that the problem
is located in the way the strings are fed into "Liste"
which is done like this from a Windows API function:

--
if FindNextFileNameW(H,Laenge,@Pfad[1]) then
   begin
   SetLength(Liste,Length(Liste)+1);
   Liste[High(Liste)] := copy(Pfad,1,Laenge);
   end;
--

where "Pfad" is a "widestring" (because of the Windows W-function),
"H" is of type "hwnd" and "Laenge" is "SizeInt".

I would expect that with the new string encoding handling
widestring will be converted automatically to "MyStringType"
(which is string in my case). This assumption is  encouraged
by the fact that "Liste" is shown with the correct list of all strings
in the evaluate window when debugging.

The interesting thing is, that *one* (the first) string
from "Liste" is added to "S" (but all others are missing).

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal