Bug #29578 documentation ASCII and ucs2
Submitted: 5 Jul 2007 18:10 Modified: 11 Jul 2007 3:47
Reporter: Martin Friebe (Gold Quality Contributor) (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.1.20 5.0.44 OS:Any
Assigned to: Paul DuBois CPU Architecture:Any
Tags: ASCII, doc

[5 Jul 2007 18:10] Martin Friebe
Description:
I believe this is most likely a documentation issue. The ASCII() function does not behave like documended.

From http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_ascii
> ASCII(str)
> Returns the numeric value of the leftmost character of the string str.
> Returns 0 if str is the empty string. Returns NULL if str is NULL.
> ASCII() works for characters with numeric values from 0 to 255. 

"leftmost character" => It works on chars, not bytes

in the example below the ucs2 character "a" is one character. And even it's represented by 2 bytes "0061", it's numerical value is 97. This is in the documented range.

How to repeat:
set names latin1;
set character_set_connection = latin1;

select ascii("a"); # returns 97

set character_set_connection = ucs2;

select ascii("a"); # returns 0

Suggested fix:
Either have ASCII work on characters (even multibyte), as documented. Or change the documentation, that ASCII works on bytes, not on chars.
[5 Jul 2007 18:37] MySQL Verification Team
Thank you for the bug report.
[11 Jul 2007 3:47] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

Changed to: ASCII() works for 8-bit characters. (Not "characters with a numeric
value from 0 to 255").