Re: [fpc-pascal] FPC 3.x for Windows and code page conversion

2015-11-23 Thread Michael Van Canneyt



On Mon, 23 Nov 2015, Lubos Pintes wrote:


Hello,
Thanks for replies, I will try to explain this in other way:
My system code page is windows-1250. When a string is sent to a COM 
component, it is somehow converted to UTF-16. Thus FPC knows how to do 
the conversion. Now I know that I am receiving text in UTF-8. Thus I 
called UTF8ToANSI to uselessly convert the UTF-8 to ANSI and then FPC 
converted it to UTF-16 to make COM happy.


Do not convert to Ansi. 
You should use unicodestring or widestring variables, and send that to COM.



Although it worked well in many cases, a data loss may occur.
So to reformulate this question, how to avoid this useless conversion 
step? I thought that setting the default code page to UTF-8 just do the 
trick.


COM only works with UTF16. The best way is to declare all strings that you 
intend to send to COM to Widestring or UnicodeString.


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


Re: [fpc-pascal] FPC 3.x for Windows and code page conversion

2015-11-23 Thread Lubos Pintes

Hello,
Thanks for replies, I will try to explain this in other way:
My system code page is windows-1250. When a string is sent to a COM 
component, it is somehow converted to UTF-16. Thus FPC knows how to do 
the conversion. Now I know that I am receiving text in UTF-8. Thus I 
called UTF8ToANSI to uselessly convert the UTF-8 to ANSI and then FPC 
converted it to UTF-16 to make COM happy.

Although it worked well in many cases, a data loss may occur.
So to reformulate this question, how to avoid this useless conversion 
step? I thought that setting the default code page to UTF-8 just do the 
trick.


Dňa 23. 11. 2015 o 17:29 Jonas Maebe napísal(a):


Lubos Pintes wrote on Mon, 23 Nov 2015:


I am developing a console application which receives an UTF-8 encoded
text through stdin.
The text is, after possible modification, sent to SAPI5. The SAPI5
generated interface wrappers have parameters of type string.
In FPC 2.6.4, I used UTF8toANSI on various places and that worked
well. Now after reading about FPC 3.x's unicode support, I thought
that adding this line say after begin in the main program could be
enough:
SetMultiByteConversionCodePage(CP_UTF8);
It however doesn't work.


That routine sets the default code page for ansistrings. It does not
change I/O.


How can I solve this without conversion to ANSI?


The code page can be set per I/O channel:
http://www.freepascal.org/docs-html/3.0.0/rtl/system/settextcodepage.html (and
Michael: I just noticed a typo on that page, under "Description" it says
GetTextCodePage instead of SetTextCodePage)


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




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

Re: [fpc-pascal] FPC 3.x for Windows and code page conversion

2015-11-23 Thread Jonas Maebe


Lubos Pintes wrote on Mon, 23 Nov 2015:

I am developing a console application which receives an UTF-8  
encoded text through stdin.
The text is, after possible modification, sent to SAPI5. The SAPI5  
generated interface wrappers have parameters of type string.
In FPC 2.6.4, I used UTF8toANSI on various places and that worked  
well. Now after reading about FPC 3.x's unicode support, I thought  
that adding this line say after begin in the main program could be  
enough:

SetMultiByteConversionCodePage(CP_UTF8);
It however doesn't work.


That routine sets the default code page for ansistrings. It does not  
change I/O.



How can I solve this without conversion to ANSI?


The code page can be set per I/O channel:  
http://www.freepascal.org/docs-html/3.0.0/rtl/system/settextcodepage.html (and  
Michael: I just noticed a typo on that page, under "Description" it  
says GetTextCodePage instead of SetTextCodePage)



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


Re: [fpc-pascal] FPC 3.x for Windows and code page conversion

2015-11-23 Thread Mattias Gaertner
On Mon, 23 Nov 2015 16:43:18 +0100
Lubos Pintes  wrote:

> Hello,
> I am developing a console application which receives an UTF-8 encoded 
> text through stdin.
> The text is, after possible modification, sent to SAPI5. The SAPI5 
> generated interface wrappers have parameters of type string.
> In FPC 2.6.4, I used UTF8toANSI on various places and that worked well. 
> Now after reading about FPC 3.x's unicode support, I thought that adding 
> this line say after begin in the main program could be enough:
> SetMultiByteConversionCodePage(CP_UTF8);

The above setting makes UTF8ToAnsi to convert the string to UTF-16 and
back to UTF-8.

> It however doesn't work.
> How can I solve this without conversion to ANSI?

Do you want to convert an UTF8 string to the system codepage?
Are you using any Lazarus units?

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


[fpc-pascal] FPC 3.x for Windows and code page conversion

2015-11-23 Thread Lubos Pintes

Hello,
I am developing a console application which receives an UTF-8 encoded 
text through stdin.
The text is, after possible modification, sent to SAPI5. The SAPI5 
generated interface wrappers have parameters of type string.
In FPC 2.6.4, I used UTF8toANSI on various places and that worked well. 
Now after reading about FPC 3.x's unicode support, I thought that adding 
this line say after begin in the main program could be enough:

SetMultiByteConversionCodePage(CP_UTF8);
It however doesn't work.
How can I solve this without conversion to ANSI?
Thanks

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


Re: [fpc-pascal] fppkg compiler upgrade

2015-11-23 Thread Michael Van Canneyt



On Mon, 23 Nov 2015, Mattias Gaertner wrote:


On Sun, 22 Nov 2015 20:55:14 -0700 (MST)
leledumbo  wrote:


What is the proper way of upgrading fppkg?


$ rm ~/.fppkg/config/default

now rerun fppkg, it should create a new config. if it still shows 2.6.4,
that means your 3.1.1 is inaccessible or has lower precedence than your
2.6.4.


Thanks.
Should I add this to the wiki?


Yes; But please mention that this is one way of doing it;
I copied the ~/.fppkg/config/default to ~/.fppkg/config/3.1.1
and then use
fppkg -c 3.1.1



Is this also needed when installing FPC with the other installers
like deb, rpm, install.sh?


Yes.

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


[fpc-pascal] Request for feedback (Issue #28725)

2015-11-23 Thread Bart
Hi,

I know times are busy with the upcoming 3.0.0.
Nevertheless I would like to get some feedback for a proposed patch
(overloaded StrUtils.PosEx for use with Uniicode strings) in the
bugtracker: http://bugs.freepascal.org/view.php?id=28725

Posting patches and not getting any feedback at all is frustrating.
Am I waisting my time?
Am I wasting fpc-devels time?

Even a "this proposal is wrong at so many levels" is better than no
reply at all.
Or a simple "Please wait until someone has time to look into it".

@all: please do not feel offended.

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


Re: [fpc-pascal] fppkg compiler upgrade

2015-11-23 Thread Mattias Gaertner
On Sun, 22 Nov 2015 20:55:14 -0700 (MST)
leledumbo  wrote:

> > What is the proper way of upgrading fppkg? 
> 
> $ rm ~/.fppkg/config/default
> 
> now rerun fppkg, it should create a new config. if it still shows 2.6.4,
> that means your 3.1.1 is inaccessible or has lower precedence than your
> 2.6.4.

Thanks.
Should I add this to the wiki?

Is this also needed when installing FPC with the other installers
like deb, rpm, install.sh?

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


Re: [fpc-pascal] Feature announcement: Generic functions, procedures and methods

2015-11-23 Thread Anthony Walter
Here is another test, a bit more complex. It fails when trying to pass a
procedure reference to the Execute. This is a bit different than
trying to get a reference to a generic routine. Routines like ControlMove
and ShapeColor and not generic.

{$mode delphi}

type
  TForEach = procedure(Item: T; Arg: A);

// inside TMainForm declaration

procedure Execute(ForEach: TForEach; Arg: A);

// implementation

procedure TMainForm.Execute(ForEach: TForEach; Arg: A);
var
  I: Integer;
begin
  for I := 0 to ComponentCount - 1 do
if Components[I] is T then
  ForEach(Components[I] as T, Arg);
end;

procedure ControlMove(Item: TControl; Arg: Integer);
begin
  Item.Left := Arg;
end;

procedure ShapeColor(Item: TShape; Arg: TColor);
begin
  Item.Brush.Color := Arg;
end;

procedure TMainForm.ExecuteButtonClick(Sender: TObject);
begin
  // below fails after "Integer>" with Compilation raised exception
internally
  Execute(ControlMove, Mouse.CursorPos.X);
  if ColorDialog.Execute then
Execute(ShapeColor, ColorDialog.Color);
end;
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Updated FPC from svn but make does not work..

2015-11-23 Thread Tomas Hajny
Hello everybody,

Could we please stick to FPC related topics on this list? I don't think
that VPN connectivity and discussion about version control systems fit
this definition. Feel free to continue these discussions in the mailing
list fpc-other.

Thank you

Tomas
(one of FPC mailing list moderators)


 Original Message 
Subject: Re: [fpc-pascal] Updated FPC from svn but make does not work..
From:"Mark Morgan Lloyd" 
Date:Mon, November 23, 2015 09:32
To:  fpc-pascal@lists.freepascal.org


Bo Berglund wrote:

> - Version control
> We use CVS at our company since 14-15 years, so I installed cvsnt on
> the RPi in order to use that against our company server. I had done
> this on a Linux Mint 13 virtual machine earlier.
> Problem: With the Pi I did not manage to set up the VPN connection to
> the company so I would be able to use it.
> This is a showstopper.

That's unfortunate but I don't have sufficient VPN experience to be able
to offer a fix (and this isn't the right place to try to thrash it out).
However I don't see why it should be happening, the RPi- particularly
the RPi2- is basically "just a computer" and stuff that runs on a PC
should run happily on it- /unless/ Raspbian has fouled up NetworkManager
(which I normally disable since it breaks various networking things that
I want to run) or systemd configuration.

I notice that there is now a pukka Debian for the RPi2 (/not/ for the
original RPi) and intend to investigate it because there are far too
many services exposed by Raspbian to make it a viable platform for e.g.
a firewall or mailserver.

http://sjoerd.luon.net/posts/2015/02/debian-jessie-on-rpi2/

> - Copy/Paste
> When asking about things here I wanted to copy code off the Pi and
> paste it on my PC. But TinyVNC and Lazarus do not work well together
> so if I Copy in Lazarus I have to first paste inside the VNC window
> into a text editor, only then is it possible to also paste in the PC.
> Inconvenient.

As I've said repeatedly, sort out your SSH so that you can tunnel an X
session over it. That will fix your C&P problems.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


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


Re: [fpc-pascal] Updated FPC from svn but make does not work..

2015-11-23 Thread Mark Morgan Lloyd

Bo Berglund wrote:


- Version control
We use CVS at our company since 14-15 years, so I installed cvsnt on
the RPi in order to use that against our company server. I had done
this on a Linux Mint 13 virtual machine earlier.
Problem: With the Pi I did not manage to set up the VPN connection to
the company so I would be able to use it.
This is a showstopper.


That's unfortunate but I don't have sufficient VPN experience to be able 
to offer a fix (and this isn't the right place to try to thrash it out). 
However I don't see why it should be happening, the RPi- particularly 
the RPi2- is basically "just a computer" and stuff that runs on a PC 
should run happily on it- /unless/ Raspbian has fouled up NetworkManager 
(which I normally disable since it breaks various networking things that 
I want to run) or systemd configuration.


I notice that there is now a pukka Debian for the RPi2 (/not/ for the 
original RPi) and intend to investigate it because there are far too 
many services exposed by Raspbian to make it a viable platform for e.g. 
a firewall or mailserver.


http://sjoerd.luon.net/posts/2015/02/debian-jessie-on-rpi2/


- Copy/Paste
When asking about things here I wanted to copy code off the Pi and
paste it on my PC. But TinyVNC and Lazarus do not work well together
so if I Copy in Lazarus I have to first paste inside the VNC window
into a text editor, only then is it possible to also paste in the PC.
Inconvenient.


As I've said repeatedly, sort out your SSH so that you can tunnel an X 
session over it. That will fix your C&P problems.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal