ext/intl: Migrate formatter, listformatter, and rangeformatter from I…#21378
Merged
Conversation
…CU C API to C++ API. - formatter: Replace intl_convert_utf8_to_utf16/uloc_getISO3Language with intl_stringFromChar/icu::Locale, use UnicodeString for pattern handling - listformatter: Replace ulistfmt_open/ulistfmt_openForType/ulistfmt_close/ ulistfmt_format with ListFormatter C++ equivalents, use UnicodeString array and intl_stringFromChar/intl_charFromString for string conversions - rangeformatter: Replace uloc_getISO3Language with icu::Locale::getISO3Language
Replace UNumberFormat*/unum_* with icu::NumberFormat C++ equivalents. Attribute get/set still use reinterpret_cast<UNumberFormat*> for now. Note: formatter_fail.phpt expectation updated because NumberFormat::createInstance() returns U_ILLEGAL_ARGUMENT_ERROR for out-of-range styles (style < 0), whereas unum_open() returned U_UNSUPPORTED_ERROR via its default switch case.
d812f7c to
e6e5a66
Compare
Member
|
I don't know C++, someone else will need to review this. |
Member
Author
@TimWolla to the rescue then :) |
TimWolla
reviewed
May 13, 2026
Member
TimWolla
left a comment
There was a problem hiding this comment.
Some remarks. I can't yet say that I fully understand the changes.
| formatted = eumalloc(formatted_len); | ||
| unum_formatDoubleCurrency(FORMATTER_OBJECT(nfo), number, scurrency, formatted, formatted_len, NULL, &INTL_DATA_ERROR_CODE(nfo)); | ||
| /* Format using CurrencyAmount. */ | ||
| icu::CurrencyAmount *currAmt = new icu::CurrencyAmount(number, ucurrency.getTerminatedBuffer(), INTL_DATA_ERROR_CODE(nfo)); |
Member
There was a problem hiding this comment.
Can this be a smart pointer / stack allocated or does this cause issues with adoptObject()?
TimWolla
approved these changes
May 16, 2026
Member
TimWolla
left a comment
There was a problem hiding this comment.
I didn't check the usage of the ICU API in detail. Given that the tests still pass, I trust you on that. From what I can tell the “C++ usage” seems correct and I'm not seeing any more obvious issues.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…CU C API to C++ API.