-
Notifications
You must be signed in to change notification settings - Fork 7.9k
GH-18345: adding Locale::isRightToLeft. #18351
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
Conversation
Checks is the locale is written left to right. It makes sure all the needed likely subtags are included (maximization) then determines the direction by known matches.
ZEND_PARSE_PARAMETERS_END(); | ||
|
||
if (!locale_len) { | ||
locale = (char *)intl_locale_get_default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about make the argument nullable and have this behavior when it's null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, understand.
thanks!
This is a new feature, so I'd like to hear other people's opinions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks fine. It's a bit weird to have both a standalone function and a static function, but I suppose this is consistent with the stuff that already exists; and there's no policy on how to deal with that?
ext/intl/locale/locale_methods.c
Outdated
locale = (char *)intl_locale_get_default(); | ||
} | ||
|
||
RETURN_BOOL(uloc_isRightToLeft((const char *)locale)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: you don't need the cast to const char*
, this will happen implicitly
size_t locale_len; | ||
|
||
ZEND_PARSE_PARAMETERS_START(1, 1) | ||
Z_PARAM_STRING(locale, locale_len) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Seems like this could be PATH_STRING because NULL bytes are treated as the end of the string.
Although it seems this is not done in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that s something I planned to revisit separately, the whole bunch.
Checks is the locale is written left to right.
It makes sure all the needed likely subtags are included (maximization) then determines the direction by known matches.