Character miscount

Поиск
Список
Период
Сортировка
Искать

Character miscount

От:
Erwin Brandstetter <brandstetter@falter.at>
Дата:
Hi developers! Hi Dave!

Testing pgAdmin III v1.6.3 rev: 6112, client Win XP, host: Debian Sarge, 
PG 8.1.9.

A pretty useful feature in the SQL query dialogue displays data about 
the current position of the cursor.

        Ln 168 Col 30 Ch 7596

"Ch" supposably stands for "Characters".
However, it is not the correct character count, but (supposably) the 
byte-length of the string. Multibyte-characters (like German umlauts ö ä 
ü) mess with the count. I stumbled across this while trying hard to fix 
a functions that wouldn't return the right length of a string. Turns 
out, the function was right, pgAdmin was wrong.

I have reported appearances of this phenomenon in various places (and 
Dave has fixed them) in the past. Maybe you can identify a typical 
function or word to look for in all of the source code to find other 
instances of the beast? (Just a thought.)


Regards
Erwin

Re: Character miscount

От:
Dave Page <dpage@postgresql.org>
Дата:
Erwin Brandstetter wrote:
> Hi developers! Hi Dave!
> 
> Testing pgAdmin III v1.6.3 rev: 6112, client Win XP, host: Debian Sarge, 
> PG 8.1.9.
> 
> A pretty useful feature in the SQL query dialogue displays data about 
> the current position of the cursor.
> 
>        Ln 168 Col 30 Ch 7596
> 
> "Ch" supposably stands for "Characters".

Yes.

> However, it is not the correct character count, but (supposably) the 
> byte-length of the string. Multibyte-characters (like German umlauts ö ä 
> ü) mess with the count. I stumbled across this while trying hard to fix 
> a functions that wouldn't return the right length of a string. Turns 
> out, the function was right, pgAdmin was wrong.

Argh - it's wxSTC::GetCurrentPos() returning the wrong value. I imagine 
it's related to the previous bug which I logged with the wx guys: 
http://sourceforge.net/tracker/index.php?func=detail&aid=1598444&group_id=9863&atid=109863

> I have reported appearances of this phenomenon in various places (and 
> Dave has fixed them) in the past. Maybe you can identify a typical 
> function or word to look for in all of the source code to find other 
> instances of the beast? (Just a thought.)

The workaround used previously involved wxSTC::SetSelection(), and 
basically not using it any more. Unfortunately there is no similar fix 
that I can think of for this case. I'll add some info on the issue to 
the wx bug and note it in our bugs file. I'm not sure there's much else 
I can do I'm afraid :-(

Thanks for the report though.

Regards, Dave.
FAQ