Re: BUG #15548: Unaccent does not remove combining diacritical characters

From: Hugh Ranalli <hugh(at)whtc(dot)ca>
To: Ramanarayana <raam(dot)soft(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15548: Unaccent does not remove combining diacritical characters
Date: 2019-02-12 16:21:35
Message-ID: CAAhbUMN-XjGQthPg5jU0Gf-+09EHVTw4m5wEUaw17QhheAEPsg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Tue, 12 Feb 2019 at 08:54, Ramanarayana <raam(dot)soft(at)gmail(dot)com> wrote:

> Hi Michael,
> The issue was that the python script was working in python 2 but not in
> python 3 in Windows. This is because the python script writes the final
> output to stdout and stdout encoding is set to utf-8 only for python 2 but
> not python 3.If no encoding is set for stdout it takes the encoding from
> the Operating system.Default encoding in linux and windows might be
> different.Hence this issue.
> Regards,
> Ram.
>
> On Tue, 12 Feb 2019 at 09:48, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
>> On Tue, Feb 12, 2019 at 02:27:31AM +0530, Ramanarayana wrote:
>> > I tested the script in python 2.7 and it works perfect. The problem is
>> in
>> > python 3.7(and may be only in windows as you were not getting the issue)
>> > and I was getting the following error
>> >
>> > UnicodeEncodeError: 'charmap' codec can't encode character '\u0100' in
>> > position 0: character maps to <undefined>
>> >
>> > I went through the python script and found that the stdout encoding is
>> set
>> > to utf-8 only if python version is <=2.
>> >
>> > I have made the same change for python version 3 as well. Please find
>> the
>> > patch for the same.Let me know if it makes sense
>>
>> Isn't that because Windows encoding becomes cp1252, utf16 or such?
>> FWIW, on Debian SID with Python 3.7, I get the correct output, and no
>> diffs on HEAD. Perhaps it would make sense to use open() on the
>> different files with encoding='utf-8' to avoid any kind of problems?
>> --
>> Michael
>
>
I can't look at this today, but will fire up Windows and Python tomorrow,
look at Ram's patch, and see what is going on. I'll also look at how we
open the input files, to see if we should supply an encoding. It makes
sense those input files will only make sense in UTF-8 anyway.

Ram, thanks for catching this issue.,

Hugh

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2019-02-12 20:19:53 BUG #15633: Data loss when reading the data from logical replication slot
Previous Message Pavlo Golub 2019-02-12 15:18:10 Re: BUG #15626: Incorrect version number shown in BigSQL installation

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Page 2019-02-12 16:28:07 Re: Should we still have old release notes in docs?
Previous Message John Naylor 2019-02-12 16:21:33 Re: use Getopt::Long for catalog scripts