Re: ascii() picks up sign bit past CHAR value 127
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: 9sch1@txl.com, pgsql-bugs@postgresql.org
Date: 2001-01-19T07:08:34Z
Lists: 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