note 112396 added to function.ord

From: Date: Tue, 11 Jun 2013 18:28:56 +0000
Subject: note 112396 added to function.ord
Groups: php.notes 
Request: Send a blank email to php-notes+get-195132@lists.php.net to get a copy of this message
Regarding character sets, and whether or not this is "ASCII". Firstly, there is no such thing as "8-bit ASCII", so if it were ASCII it would only ever return integers up to 127. 8-bit ASCII-compatible encodings include the ISO 8859 family of encodings, which map various common characters to the values from 128 to 255. UTF-8 is also designed so that characters representable in 7-bit ASCII are coded the same; byte values higher than 127 in a UTF-8 string represent the beginning of a multi-byte character. In fact, like most of PHP's string functions, this function isn't doing anything to do with character encoding at all - it is just interpreting a binary byte from a string as an unsigned integer. That is, ord(chr(200)) will always return 200, but what character chr(200) *means* will vary depending on what character encoding it is *interpreted* as part of (e.g. during display). A technically correct description would be "Returns an integer representation of the first byte of a string, from 0 to 255. For single-byte encodings such as (7-bit) ASCII and the ISO 8859 family, this will correspond to the first character, and will be the position of that character in the encoding's mapping table. For multi-byte encodings, such as UTF-8 or UTF-16, the byte may not represent a complete character." The link to asciitable.com should also be replaced by one which explains what character encoding it is displaying, as "Extended ASCII" is an ambiguous and misleading name. ---- Server IP: 94.76.225.145 Probable Submitter: 62.189.198.114 ---- Manual Page -- http://php.net/manual/en/function.ord.php Edit -- https://master.php.net/note/edit/112396 Del: integrated -- https://master.php.net/note/delete/112396/integrated Del: useless -- https://master.php.net/note/delete/112396/useless Del: bad code -- https://master.php.net/note/delete/112396/bad+code Del: spam -- https://master.php.net/note/delete/112396/spam Del: non-english -- https://master.php.net/note/delete/112396/non-english Del: in docs -- https://master.php.net/note/delete/112396/in+docs Del: other reasons-- https://master.php.net/note/delete/112396 Reject -- https://master.php.net/note/reject/112396 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#195132) next »