-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1619,3 +1619,19 @@ PHP_FUNCTION(locale_accept_from_http) | |
RETURN_STRINGL(resultLocale, len); | ||
} | ||
/* }}} */ | ||
|
||
PHP_FUNCTION(locale_is_right_to_left) | ||
{ | ||
char *locale; | ||
size_t locale_len; | ||
|
||
ZEND_PARSE_PARAMETERS_START(1, 1) | ||
Z_PARAM_STRING(locale, locale_len) | ||
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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I see, understand. |
||
} | ||
|
||
RETURN_BOOL(uloc_isRightToLeft(locale)); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--TEST-- | ||
locale_is_right_to_left | ||
--EXTENSIONS-- | ||
intl | ||
--FILE-- | ||
<?php | ||
var_dump(Locale::isRightToLeft("en-US")); | ||
var_dump(Locale::isRightToLeft("\INVALID\\")); | ||
var_dump(Locale::isRightToLeft("")); | ||
var_dump(Locale::isRightToLeft("ar")); | ||
?> | ||
--EXPECT-- | ||
bool(false) | ||
bool(false) | ||
bool(false) | ||
bool(true) |
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.