Re: Trim not working (PostgreSQL 9.1.2 on Win64)

From: Edson Richter <edsonrichter(at)hotmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Trim not working (PostgreSQL 9.1.2 on Win64)
Date: 2012-07-29 01:24:00
Message-ID: BLU0-SMTP197495B684B8B09E4AB21A3CFC70@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Em 28/07/2012 19:41, Tom Lane escreveu:
> Edson Richter <edsonrichter(at)hotmail(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2012-07-29 08:03:04 array_length of an empty array
Previous Message Edson Richter 2012-07-29 00:53:53 Re: Trim not working (PostgreSQL 9.1.2 on Win64)