Recent

Author Topic: ANSI Chars GTK2 SVN  (Read 18705 times)

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
RE: Re: RE: Re: RE: ANSI Chars GTK2 SVN
« Reply #15 on: August 26, 2007, 11:30:34 pm »
Thanks Phil for the explanation.

There's still one thing I don't understand:

Three tests:

1. Memo1.text:=UTF8Encode(WideChar($00B6));
2. Memo1.text:=AnsiToUTF8(#$B6);
3. Memo1.text:=#$B6;    

On Lazarus 0.9.22 GTK1:
1. shows the ¶
2. shows the ¶
3. shows nothing

But on SVN 11856 GTK1:
1. shows the ¶
2. shows a ?
3. shows nothing

I'm using the same compiler for both versions. The conversion functions are defined in the FPC RTL.
Isn't this strange?

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: RE: Re: RE: Re: RE: ANSI Chars GTK2 SVN
« Reply #16 on: August 27, 2007, 01:41:01 am »
Quote from: "theo"
I'm using the same compiler for both versions. The conversion functions are defined in the FPC RTL.
Isn't this strange?


Check to make sure the 2 functions are returning the same strings:

var
  s : string;
begin
  s := UTF8Encode(WideChar($00B6));
  writeln(byte(s[1]), ' ', byte(s[2]));
  s := AnsiToUTF8(#$B6);
  writeln(byte(s[1]), ' ', byte(s[2]));
end.

You should get 194 ($C2) and 182 ($B6) for both.

I tested it here on Windows and OS X and everything checks out.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
RE: Re: RE: Re: RE: Re: RE: ANSI Chars GTK2 SVN
« Reply #17 on: August 27, 2007, 12:09:20 pm »
I'm really getting different results from this using the same compiler:

Lazarus 0.9.22 GTK1:
194 182
194 182

SVN 11856 GTK1:
194 182
63 0

I've installed the stable version as root and the SVN version under ~/
Different environment? But I have no start-scripts. My $LANG is "de_CH.UTF-8" for both.

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: RE: Re: RE: Re: RE: Re: RE: ANSI Chars GTK2 SVN
« Reply #18 on: August 27, 2007, 03:30:17 pm »
Quote from: "theo"
I'm really getting different results from this using the same compiler:

Lazarus 0.9.22 GTK1:
194 182
194 182

SVN 11856 GTK1:
194 182
63 0

I've installed the stable version as root and the SVN version under ~/
Different environment? But I have no start-scripts. My $LANG is "de_CH.UTF-8" for both.


That certainly looks like a bug in the SVN AnsiToUTF8 function. One last thing to test:

s : AnsiToUTF8(Chr($B6));

Just to make sure the compiler isn't mangling the character stored in the executable.

Please post the sample code when you make your bug report on Mantis.

Thanks.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
RE: Re: RE: Re: RE: Re: RE: Re: RE: ANSI Chars GTK2 SVN
« Reply #19 on: August 27, 2007, 08:20:25 pm »
I don't think so because this function is defined in the FPC sources and I have only one version of FPC installed.
Both, Stable and SVN Version of Lazarus use the same compiler and RTL/FCL.

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: RE: Re: RE: Re: RE: Re: RE: ANSI Chars GTK2 SVN
« Reply #20 on: September 01, 2007, 10:41:31 pm »
Quote from: "theo"
I'm really getting different results from this using the same compiler:

Lazarus 0.9.22 GTK1:
194 182
194 182

SVN 11856 GTK1:
194 182
63 0


Theo,

Did you ever solve this problem.

It appears as though these conversion functions return 63 ("?") if they encounter a character they can't convert. There shouldn't be a problem with #$B6. However, I've discovered that if you include the LCL Translations unit in your app, this uses the cwstring unit, which uses libc for wide string support (assuming LCL was compiled with DisableCWString not defined). I think there's a bug in cwstring with >127 ANSI chars.

Thanks.

-Phil

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1890
RE: Re: RE: Re: RE: Re: RE: Re: RE: ANSI Chars GTK2 SVN
« Reply #21 on: September 01, 2007, 11:20:57 pm »
> Did you ever solve this problem.
No. Because it's not a real problem for me now just a mistery, and I have no idea where to "attack" ;-)
I'll check the "cwstring" later.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: RE: Re: RE: Re: RE: Re: RE: Re: RE: ANSI Chars GTK2 SVN
« Reply #22 on: September 02, 2007, 12:27:25 am »
Quote from: "theo"
No. Because it's not a real problem for me now just a mistery, and I have no idea where to "attack" ;-)


I would try asking on the Free Pascal mailling list. Maybe the compiler experts have an idea of what is going wrong.