Jens Schmidt on Fri, 21 Apr 2017 11:39:08 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: PARI/GP for Windows doesn't support umlauts and diacritical signs but it's possible


Bill Allombert schrieb:
> On Wed, Apr 19, 2017 at 01:42:56PM +0200, Bill Allombert wrote:
>> On Wed, Apr 19, 2017 at 07:42:41AM +0200, Jens Schmidt wrote:
>>> PARI/GP for Windows only supports ASCII chars in input and output. The
>>> programm should set the both codepages for input and output to the
>>> default value given by Windows registry (called ACP: ANSI codepage).
>>> That is easily done by some C code at startup:
>>>
>>>   SetConsoleCP( GetACP() );
>>>   SetConsoleOutputCP( GetACP() );
>>>
>>> By default the codepage of a Windows console is set to ancient DOS 437
>>> or 850,... called OEMCP. These old OEM codepages aren't recommend.
>>>
>>> ACP is CP 1252 by default (aka Western) which is nearly identical to
>>> ISO-8859-1 and UTF-8 (Latin1 block). Windows uses some of the characters
>>> 0x80 .. 0x9f which are non-printable chars in ISO-8859-1 and UTF-8.
>>>
>>> Windows has very limited support for UTF-8 console (codepage 65001).
>>> UTF-8 file/console redirect isn't possible because Windows doesn't
>>> support multibyte file IO - only single byte and wide chars.
>>>
>>> I've tested this with Windows 7 and Wine in Linux. Setting codepages
>>> functions too through a PARI/GP plugin which could be installed at any
>>> time and would make older versions working.
>>
>> Hello Jens,
>> Thanks for your suggestion.
>> I tried to write a patch following your suggestion but it did not seem
>> to change anything on wine. See below.
> 
> Actually it works when readline is disabled.
> 
> Cheers,
> Bill.
> 

There is another related? effect with readline and colors in Windows
(not only in Wine).

To test this start clean PARI/GP without any preloaded defaults in a
windows console:

  gp -f
  default(prompt, "gp >")
  default(colors, brightfg)
  default(readline, 0)

The white prompt switches to yellow color and brightness on. Now type:

  default(readline, 4)

The prompt switches back to white color and brightness off. This
should'nt happen.


I remember that there was a similar effect with colors using setfont()
in Linux (which has nothing to do with readline, but the underlaying
hardware is the same).

See 'man 8 setfont' -> NOTE

   PC video hardware allows one to use the "intensity" bit either to indi‐
   cate brightness, or to address 512 (instead of 256) glyphs in the font.
   So, if the font has more than 256 glyphs, the console will  be  reduced
   to 8 (instead of 16) colors.

There goes somthing wrong with readline and signedness of characters and
color bits because all special chars must have highest bit 7 set. It
seems that readline clears highest character bit 7 what makes use of
special chars impossible. Switching readline off enables some bits and
prompt color is changing to yellow and special chars are working.

Color attribute bits are part of a character in console mode:
https://en.wikipedia.org/wiki/VGA-compatible_text_mode#Text_buffer

LG - Jens