Re: [Lazarus] Garbage writing to console

2018-02-22 Thread Mattias Gaertner via Lazarus
On Fri, 23 Feb 2018 08:44:23 +0100
Ondrej Pokorny via Lazarus  wrote:

> OK, sorry. I wrote bullshit. But still, you should ask on fpc-devel list 
> regarding compiler issues - the right people are there.

fpc-devel is about development of the compiler.
fpc-pascal is for normal user questions.

But this is a Lazarus issue.

Mattias
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Garbage writing to console

2018-02-22 Thread Ondrej Pokorny via Lazarus
OK, sorry. I wrote bullshit. But still, you should ask on fpc-devel list 
regarding compiler issues - the right people are there.


Ondrej
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Garbage writing to console

2018-02-22 Thread Luca Olivetti via Lazarus

El 22/02/18 a les 22:26, Ondrej Pokorny via Lazarus ha escrit:

On 22.02.2018 12:21, Luca Olivetti via Lazarus wrote:
Lazarus 1.8.0, fpc 3.0.4, windows application (with "win32 gui 
application unchecked") or console application (using LazUTF8).

File encoding utf-8 without bom.

writeln('áéí')

produces garbage, contrary to what's said in 
http://wiki.freepascal.org/Unicode_Support_in_Lazarus#Writing_to_console


No, it's not contrary - just the opposite. The problem is that áéí (ANSI 
1250 or whatever) have different codes to your console codepage (CP437 
or whatever). You should open/edit your program source code in your 
console codepage - you obviously edit it in ANSI.


Uh? It's utf-8


"When you convert the code to UTF-8, for example by using Lazarus' 
source editor popup menu item File Settings / Encoding / UTF-8 and 
clicking on the dialog button "Change file on disk", the ╩ becomes 3 
bytes (#226#149#169), so the literal becomes a string. *The procedures 
write and writeln convert the UTF-8 string to the current console 
codepage*. So your console program now outputs the '╩' on Windows with 
any codepage (i.e. not only CP437) and it even works on Linux and Mac OS X."


Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Compilation aborted!

2018-02-22 Thread Virgo Pärna via Lazarus
On Thu, 22 Feb 2018 10:29:34 + (UTC), Virgo Pärna via Lazarus 
 wrote:
> On Sun, 18 Feb 2018 12:51:49 -0500, Donald Ziesig via Lazarus 
>  wrote:
>>
>>    TAMBytes = array[0..High(Integer)] of Byte;
>>
>
>   Was it 32 bit compiler? Because 2GB - 1 byte array would really
> be problem with 32 bit programs. But ofcause it should not result in Access 
> Violation.
>

Correction: actully 2GB. Forgot 0th byte.

-- 
Virgo Pärna 
virgo.pa...@mail.ee

-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Garbage writing to console

2018-02-22 Thread Ondrej Pokorny via Lazarus

On 22.02.2018 12:21, Luca Olivetti via Lazarus wrote:
Lazarus 1.8.0, fpc 3.0.4, windows application (with "win32 gui 
application unchecked") or console application (using LazUTF8).

File encoding utf-8 without bom.

writeln('áéí')

produces garbage, contrary to what's said in 
http://wiki.freepascal.org/Unicode_Support_in_Lazarus#Writing_to_console


No, it's not contrary - just the opposite. The problem is that áéí (ANSI 
1250 or whatever) have different codes to your console codepage (CP437 
or whatever). You should open/edit your program source code in your 
console codepage - you obviously edit it in ANSI.



The strange thing is that:

procedure w(const s:string);
begin
  writeln(s);
end;

w('áéí')

also gives the correct output.


It looks like writeln ignores the codepage for constant strings but 
checks it for "normal" strings. You should ask on fpc-devel list for 
details.


Ondrej
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Garbage writing to console

2018-02-22 Thread Luca Olivetti via Lazarus

El 22/02/18 a les 13:46, Luca Olivetti via Lazarus ha escrit:

El 22/02/18 a les 13:07, Tony Whyman via Lazarus ha escrit:
You may find the "SetTextCodePage" procedure useful when it comes to 
setting the code page for a Windows console.


e.g. SetTextCodePage(stdout,cp_utf8);


Same result: garbage with writeln, correct result with w


Unsurprising since it's already cp_utf8 (according to GetTextCodePage)

Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Garbage writing to console

2018-02-22 Thread Luca Olivetti via Lazarus

El 22/02/18 a les 13:07, Tony Whyman via Lazarus ha escrit:
You may find the "SetTextCodePage" procedure useful when it comes to 
setting the code page for a Windows console.


e.g. SetTextCodePage(stdout,cp_utf8);


Same result: garbage with writeln, correct result with w




See also 
https://www.freepascal.org/docs-html/rtl/system/settextcodepage.html



On 22/02/18 11:21, Luca Olivetti via Lazarus wrote:
Lazarus 1.8.0, fpc 3.0.4, windows application (with "win32 gui 
application unchecked") or console application (using LazUTF8).

File encoding utf-8 without bom.

writeln('áéí')

produces garbage, contrary to what's said in 
http://wiki.freepascal.org/Unicode_Support_in_Lazarus#Writing_to_console


using {$codepage utf8} (or utf-8 with bom) fixes it, but I'm not sure 
it's recommended to do so: 
http://wiki.freepascal.org/Unicode_Support_in_Lazarus#String_Literals


The strange thing is that:

procedure w(const s:string);
begin
  writeln(s);
end;

w('áéí')


also gives the correct output.
Why? After all I'm using the same string literal.
I suppose there's some underlying automatic conversion going on, but 
it's very confusing.


Bye





--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Garbage writing to console

2018-02-22 Thread Tony Whyman via Lazarus
You may find the "SetTextCodePage" procedure useful when it comes to 
setting the code page for a Windows console.


e.g. SetTextCodePage(stdout,cp_utf8);

See also 
https://www.freepascal.org/docs-html/rtl/system/settextcodepage.html



On 22/02/18 11:21, Luca Olivetti via Lazarus wrote:
Lazarus 1.8.0, fpc 3.0.4, windows application (with "win32 gui 
application unchecked") or console application (using LazUTF8).

File encoding utf-8 without bom.

writeln('áéí')

produces garbage, contrary to what's said in 
http://wiki.freepascal.org/Unicode_Support_in_Lazarus#Writing_to_console


using {$codepage utf8} (or utf-8 with bom) fixes it, but I'm not sure 
it's recommended to do so: 
http://wiki.freepascal.org/Unicode_Support_in_Lazarus#String_Literals


The strange thing is that:

procedure w(const s:string);
begin
  writeln(s);
end;

w('áéí')


also gives the correct output.
Why? After all I'm using the same string literal.
I suppose there's some underlying automatic conversion going on, but 
it's very confusing.


Bye


--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] Garbage writing to console

2018-02-22 Thread Luca Olivetti via Lazarus
Lazarus 1.8.0, fpc 3.0.4, windows application (with "win32 gui 
application unchecked") or console application (using LazUTF8).

File encoding utf-8 without bom.

writeln('áéí')

produces garbage, contrary to what's said in 
http://wiki.freepascal.org/Unicode_Support_in_Lazarus#Writing_to_console


using {$codepage utf8} (or utf-8 with bom) fixes it, but I'm not sure 
it's recommended to do so: 
http://wiki.freepascal.org/Unicode_Support_in_Lazarus#String_Literals


The strange thing is that:

procedure w(const s:string);
begin
  writeln(s);
end;

w('áéí')


also gives the correct output.
Why? After all I'm using the same string literal.
I suppose there's some underlying automatic conversion going on, but 
it's very confusing.


Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Compilation aborted!

2018-02-22 Thread Virgo Pärna via Lazarus
On Sun, 18 Feb 2018 12:51:49 -0500, Donald Ziesig via Lazarus 
 wrote:
>
>    TAMBytes = array[0..High(Integer)] of Byte;
>

Was it 32 bit compiler? Because 2GB - 1 byte array would really
be problem with 32 bit programs. But ofcause it should not result in Access 
Violation.

-- 
Virgo Pärna 
virgo.pa...@mail.ee

-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus