-
Notifications
You must be signed in to change notification settings - Fork 732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potentially Confusing Function Description of mb_ord() #2963
Comments
A number is a number - there is no "decimal notation" for it. It's like talking about a timezone for a Unix timestamp. Personally, I'd keep the description, then add a note along the lines of
and update/add an example like <?php
printf("This elephant 🐘 is Unicode character U+%04X", mb_ord("🐘"));
?>
|
Unicode code points are not hexadecimal, they are numbers, representing them as hexadecimals is just a convenience thing, like with a lot of things in computing due to it being a somewhat nicer way to represent binary. |
Decimal notation means just the number in base 10 and not base 16. The comparison with time zones would make more sense if you think of base 10 as one time zone and base 16 as another. Or Unix timestampe and Unix timestamp in hexadecimal base. I checked the documentation and the convention is to use hexadecimal numbers: https://www.unicode.org/versions/Unicode15.1.0/appA.pdf |
A number is a number, regardless of its representation. And what you are saying makes no sense. A codepoint is a number it doesn't care about its representation, be that binary, octal, decimal, hexadecimal, in base 425 it is still a number. And PHP uses the The fact that something requires a specific representation of a number is, frankly, none of the business of this function, or any other function returning |
Look, all I was trying to say is that Unicode code points are generally given/represented in a hexadecimal notation, it' the Unicode convention. Someone who reads up on the function might be confused that it returns the value in decimal and I think it makes sense to add a sentence as an explanation to the description. That was my point and to me it makes sense. |
From manual page: https://php.net/function.mb-ord
The description is potentially confusing, as Unicode code point values are hexadecimal, whereas the function returns the decimal value. So for 'A', the return value is 65, not 41.
This:
Should look like this:
The text was updated successfully, but these errors were encountered: