Re: ascii() picks up sign bit past CHAR value 127

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: ascii() picks up sign bit past CHAR value 127
Дата
Msg-id 7574.979888114@sss.pgh.pa.us
обсуждение исходный текст
Ответ на ascii() picks up sign bit past CHAR value 127  (pgsql-bugs@postgresql.org)
Список pgsql-bugs
pgsql-bugs@postgresql.org writes:
> The lack of an UNISIGNED INT1 attribute type forces those of us who
> need a positive numeric byte type to use CHAR.  The ascii() function
> ostensibly returns the numeric ASCII value of the corresponding CHAR
> attribute value - but once you get beyond the 0-127 ACCII character
> value range, the ascii() function starts picking up the active high
> order bit as a sign bit.  This is not too surprising but it is a bit
> bizarre since I tend to think of character encoding standards having
> the option of using the 127-255 character values.

If you use gcc, you could probably recompile the backend with
-funsigned-char to make ascii() work the way you want.

On a machine where char is considered signed, I'm not sure that
ascii()'s behavior is wrong ... could argue that either way I suppose.

            regards, tom lane

В списке pgsql-bugs по дате отправления:

Предыдущее
От: pgsql-bugs@postgresql.org
Дата:
Сообщение: ascii() picks up sign bit past CHAR value 127
Следующее
От: pgsql-bugs@postgresql.org
Дата:
Сообщение: Not using indexes in WHERE clauses