Re: Trim not working (PostgreSQL 9.1.2 on Win64) - Mailing list pgsql-general

From Edson Richter
Subject Re: Trim not working (PostgreSQL 9.1.2 on Win64)
Date
Msg-id BLU0-SMTP197495B684B8B09E4AB21A3CFC70@phx.gbl
Whole thread Raw
In response to Re: Trim not working (PostgreSQL 9.1.2 on Win64)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Em 28/07/2012 19:41, Tom Lane escreveu:
> Edson Richter <edsonrichter@hotmail.com> writes:
>> If I do apply trim over the substring, no spaces are removed, and I
>> cannot understand why.
>> ...
>> But using the regular expression matching "^\s*" and "\s*$" works, and
>> spaces are removed:
> I think what this means is that what you say are runs of spaces are no
> such thing, but are some other whitespace character(s).  Perhaps tabs,
> or non-breaking spaces?
>
>             regards, tom lane
>
By all means, you are right.
I supposed they are spaces... at least in the original CVS file.
I've used an Hex editor, and they are character C2A0 (UTF-8) in the file.
Now, executing the following query surprises me:

select rslinha2,
        ascii(substring(rslinha2 from 3 for position('(+)' in rslinha2)-4))
   from plan_maio
  limit 1

resulted in the following:

"2. TAXA VIGILANCIA                                   (+) R$ 13,00";160

So, file_fdw converted my original spaces into character 160.
That's the reason for trim not working.

Thanks for your toughs. You led me to the right direction: when
importing data from files, not always what looks like is what it is.


Regards,

Edson Richter.


pgsql-general by date:

Previous
From: Edson Richter
Date:
Subject: Re: Trim not working (PostgreSQL 9.1.2 on Win64)
Next
From: John R Pierce
Date:
Subject: array_length of an empty array