Commit graph

49 commits

Author SHA1 Message Date
Fredrik Roubert
3f5fd0df73 ICU-22901 Update ulocimp_canonicalize() &co. to use std::string_view. 2025-02-13 15:50:54 +01:00
Fredrik Roubert
5463eac8b4 ICU-22901 Update ulocimp_getKeywords() to use std::string_view. 2025-02-13 15:50:54 +01:00
Fredrik Roubert
424d6a3e8b ICU-22901 Update ulocimp_getSubtags() &co. to use std::string_view. 2024-11-22 19:05:03 +01:00
Frank Tang
5e22f0076e ICU-22854 Implement subdivision validation 2024-08-22 11:02:36 -07:00
Fredrik Roubert
7ffbe77e12 ICU-22696 Update ulocimp_setKeywordValue() to use std::string_view. 2024-08-13 14:03:18 +02:00
Fredrik Roubert
8a6d59ec80 ICU-22696 Update ulocimp_to*{Key,Type}() to use std::string_view. 2024-08-07 14:14:23 +02:00
Fredrik Roubert
dd65ee3f0b ICU-22696 Update ulocimp_getKeywordValue() to use std::string_view. 2024-07-31 15:39:15 +02:00
Fredrik Roubert
5d7cbdbc02 ICU-22696 Delete unused code.
These optional output parameters weren't used when these function were
originally added so they were most likely included just in case someone
would want to use them in the future, but that was 10 years ago now and
they still haven't been used yet, so it's unlikely that they'll be used
in the foreseeable future and call sites as well as the implementation
can instead be simplified by removing them.
2024-07-29 22:03:10 +02:00
Fredrik Roubert
53568e8dfc ICU-22520 Refactor CharString & CharStringByteSink into helper.
The repeated sequence of allocating a CharString and CharStringByteSink,
before calling some function that writes into this, can be moved into a
single shared helper function which then is used to give all ulocimp.h
functions that write to ByteSink an overload that instead returns a
CharString, to make call sites look like perfectly normal C++ code.
2024-03-05 23:44:50 +01:00
Fredrik Roubert
939f08f274 ICU-22520 Use C++ function signatures for internal C++ functions.
Some of this code was originally written as C code and some of this code
was originally written as C++ code but made to resemble the then already
existing code that had once been C code. Changing it all to normal C++
now will make it easier and safer to work with going forward.

· Use unnamed namespace instead of static.
· Use reference instead of non-nullable pointer.
· Use bool instead of UBool.
· Use constexpr for static data.
· Use U_EXPORT instead of U_CAPI or U_CFUNC.
· Use the default calling convention instead of U_EXPORT2.
2024-02-12 21:44:06 +01:00
Fredrik Roubert
63ae786bf7 ICU-22520 Refactor function macros into inline functions.
This is to facilitate further refactoring of the locale code.
2024-02-08 14:24:48 +01:00
Fredrik Roubert
a6efa924ad ICU-22520 Let ulocimp_getRegionForSupplementalData() return CharString. 2024-02-07 14:27:40 +01:00
Fredrik Roubert
930b4d9ab9 ICU-22520 Add convenience wrappers for calling ulocimp_getSubtags().
These wrappers that call ulocimp_getSubtags() to get only one particular
subtag and then return that as icu::CharString will be convenient for
replacing code that currently calls the uloc_get*() functions writing
into a fixed size buffer.
2024-02-06 19:53:53 +01:00
Fredrik Roubert
835b009314 ICU-22520 Make ulocimp_get*() internal to ulocimp_getSubtags().
These functions now no longer have any other callers so they can be made
internal to the compilation unit of ulocimp_getSubtags(), thus bringing
them back to how they originally were intended to be used (and making
the comment above them true once again).

This also makes it possible to remove the temporary icu::CharString
objects that previously were returned to callers and instead write
directly to icu::ByteSink, making the code both simpler and less
wasteful (also that how this was once intended).
2024-02-06 13:12:55 +01:00
Fredrik Roubert
dc70b5a056 ICU-22520 Move all localeID parsing logic into new ulocimp_getSubtags().
The logic for parsing a localeID string into its constituent subtags is
currently repeated over and over again in each one of the uloc_get*()
functions, so that calling all these functions one after the other in
order to get all the subtags does the parsing all over again from the
beginning for each function call.

In order to avoid having to do this parsing over and over again, a lot
of code instead has its own copy of the parsing logic in order to call
the underlying ulocimp_get*() functions directly for lower runtime cost
at the price of increased code complexity and repetition.

This new ulocimp_getSubtags() function, which writes natively to
icu::ByteSink and has a convenience wrapper to write to icu::CharString,
removes the repeated code from the uloc_get*() functions and makes it
possible to update all code that calls the ulocimp_get*() functions.
2024-02-06 13:12:55 +01:00
Fredrik Roubert
1b0f5e41c5 ICU-22520 Switch to using CharString for calling uloc_setKeywordValue(). 2024-01-30 12:04:53 +01:00
Fredrik Roubert
340806bf9a ICU-22520 Add a ulocimp_setKeywordValue() that writes to icu::ByteSink. 2024-01-30 12:04:53 +01:00
Fredrik Roubert
037449fff8 ICU-21289 Switch to using CharString for calling uloc_getParent(). 2023-09-26 23:41:24 +02:00
Fredrik Roubert
96dcaf7da8 ICU-21289 Switch to using CharString for calling uloc_forLanguageTag(). 2023-09-26 17:52:51 +02:00
Frank Tang
ffc449de62 ICU-20777 Merge the likelySubtags implemention
Change testdata/likelySubtags.txt to consider FAIL line

ICU-20777 Fix Java Tests

ICU-20777 Fix all issues

ICU-20777 Incase timeout

ICU-20777

ICU-20777 Skip Data Driven test
2023-08-18 09:35:54 -07:00
Markus Scherer
2864379937 ICU-21833 replace U_NOEXCEPT with C++11 standard noexcept 2023-03-01 15:24:34 -08:00
Rich Gillam
b03b8be741 ICU-21639 Added an internal utility class to streamline preflighting and heap-allocating a char buffer for a locale ID
and changed several internal methods in ULocale to use it, so that they work correctly on locale IDs that are longer
than ULOC_FULLNAME_CAPACITY.
2021-08-02 13:15:29 -07:00
Frank Tang
5f8df0d288 ICU-21406 canonicalize -T- extension
See #1491
2020-12-07 21:21:41 -08:00
Frank Tang
12dc3772b1 ICU-21236 Correct Locale canonicalization
See #1254
2020-09-21 19:35:13 -07:00
Markus Scherer
a18df7ba28 ICU-21267 stop using FALSE & TRUE macros in most library-internal headers 2020-09-10 13:55:46 -07:00
Markus Scherer
18c4a69f80 ICU-9961 replace U_DRAFT/U_STABLE/U_INTERNAL with U_CAPI 2020-09-10 11:23:44 -07:00
Fredrik Roubert
f9ada4b3cb ICU-21035 Pass ByteSink from Locale::getKeywordValue() to uloc_getKeywordValue().
This eliminates the need for a scratch buffer in Locale::getKeywordValue()
and also the need for counting bytes required in uloc_getKeywordValue(),
something that ByteSink will now handle correctly.
2020-09-03 00:48:43 +02:00
Fredrik Roubert
05d49fd373 ICU-21035 Replace backward compatibility locale_getKeywords() function.
By updating the last 3 callers to do dynamic memory allocation instead,
the fixed memory buffer function becomes obsolete.
2020-08-27 13:46:07 +02:00
Fredrik Roubert
e8f3d5c657 ICU-21035 Replace backward compatibility ulocimp_getCountry() overload.
By always calling the dynamic memory allocation implementation directly
instead, the fixed memory buffer boundary gets pushed one step further
towards the edges.
2020-08-26 13:48:54 +02:00
Fredrik Roubert
db3278a71e ICU-21035 Replace backward compatibility ulocimp_getScript() overload.
By always calling the dynamic memory allocation implementation directly
instead, the fixed memory buffer boundary gets pushed one step further
towards the edges.
2020-08-25 00:30:54 +02:00
Markus Scherer
39da689d30 ICU-21184 rephrase docs/comments using the term grandfathered 2020-08-21 14:13:03 -07:00
Fredrik Roubert
3a8e0a2fe9 ICU-21035 Replace backward compatibility ulocimp_getLanguage() overload.
By always calling the dynamic memory allocation implementation directly
instead, the fixed memory buffer boundary gets pushed one step further
towards the edges.
2020-08-20 23:38:30 +02:00
Fredrik Roubert
879f6728f0 ICU-20803 Pass ByteSink to _canonicalize().
This eliminates the need for the fixed size scratch buffer inside of
locale_set_default_internal() and also eliminates the need for counting
bytes, something that ByteSink and CharString now will handle correctly,
when needed.

None of this should have any externally visible effect (apart from
removing the arbitrary size limit imposed by the fixed size scratch
buffer), it's all about cleaning up implementation internals.
2020-03-27 17:47:32 +01:00
Fredrik Roubert
01c69cfa85 ICU-20158 Pass ByteSink all the way to _uloc_(addLikely|minimize)Subtags().
This eliminates the need for scratch buffers in any code path that ends
with these functions and also eliminates the need for counting bytes,
something that ByteSink will now handle correctly when needed.

Existing calls to uloc_addLikelySubtags() and uloc_minimizeSubtags()
throughout ICU4C implementation code are also updated to instead use
either the Locale or ulocimp_* functions with the new API.

None of this should have any externally visible effect, it's all about
cleaning up implementation internals.
2019-02-21 12:19:04 +01:00
Frank Tang
6942013a38 ICU-20328 Implement LocaleBuilder
Design Doc: https://goo.gl/Qf12p3
2019-02-13 17:24:38 -08:00
Fredrik Roubert
47ecbc4915 ICU-20158 Pass ByteSink from Locale::forLanguageTag() to uloc_forLanguageTag().
This eliminates the need for a scratch buffer in Locale::forLanguageTag()
and also the need for counting bytes required in uloc_forLanguageTag(),
something that ByteSink will now handle correctly.
2018-10-31 12:21:15 +01:00
Fredrik Roubert
59fe4f4be2 ICU-20132 Pass ByteSink from Locale::toLanguageTag() to uloc_toLanguageTag().
This eliminates the need for a scratch buffer in Locale::toLanguageTag()
and also the need for counting bytes required in uloc_toLanguageTag(),
something that ByteSink will now handle correctly and thereby
eliminating the bug where too few bytes required was returned.
2018-10-25 21:04:47 +02:00
Andy Heninger
19a29f956e
ICU-20119 ICU4C 63 API promotion & change report (#161)
* ICU-20119 ICU4C 63 API promotion, work in progress.

* ICU-20119 ICU4C 63 API promotion, work in progress.

* ICU-20119 ICU 63 API promotion & change report

* ICU-20119 ICU4C 63 API change report, new draft, still work in progress.

* ICU-20119 ICU4C 63 API change report, another new draft, still work in progress.

* ICU-20119 ICU4C 63 API change report, another new draft.

* ICU-20119 ICU4C 63 API change report, after @preview revert. Hopefully the final rev.

* ICU-20119 ICU4C 63 API change report, clean up a few minor html errors.
2018-09-28 09:36:25 -07:00
Fredrik Roubert
cc6c31432e
ICU-13417 Pass length from Locale::forLanguageTag() to ultag_parse().
If not passed a length, ultag_parse() will call uprv_strlen(), requiring
the input buffer to be NUL terminated. This is unnecessary.
2018-09-27 14:27:41 -07:00
Andy Heninger
242e02c388 ICU-12764 icu4c utf-8 source files, update Copyright notices.
X-SVN-Rev: 39583
2017-01-20 00:20:31 +00:00
Michael Ow
61607c2773 ICU-12564 Update copyright notice in trunk
X-SVN-Rev: 38848
2016-06-15 18:58:17 +00:00
Yoshito Umaoka
00ca13e126 ICU-12564 Reverted r38761 and r38762, because we want to prepend the Unicode copyright for existing source files, instead of replacing copyright comments.
X-SVN-Rev: 38776
2016-05-31 21:45:07 +00:00
Michael Ow
c9f199a30f ICU-12564 Update copyright notice in ICU4C
X-SVN-Rev: 38761
2016-05-26 22:32:17 +00:00
Peter Edberg
086ee675a8 ICU-12085 manually integrate branch > trunk (had network problems committing updated branch)
X-SVN-Rev: 38311
2016-02-15 17:58:23 +00:00
Yoshito Umaoka
8885f1ef78 ICU-8951 BCP 47 key/type converter APIs merged from the work branch.
X-SVN-Rev: 36320
2014-09-03 04:42:21 +00:00
Umesh Nair
eb9d3b2708 ICU-7023 Fix import for EBCDIC machines - contd
X-SVN-Rev: 29010
2010-11-06 00:30:20 +00:00
Markus Scherer
ea551a1d7f ICU-7164 split locale API implementation into multiple files so that core locale ID .c/.cpp files (hopefully) do not depend on resource bundle code or data any more
X-SVN-Rev: 27685
2010-02-25 22:32:39 +00:00
Doug Felt
18b87b0965 ICU-7342 add LocaleDisplayNames and rudimentary test. Fix Locale.getVariant problem and add test.
X-SVN-Rev: 27258
2010-01-14 02:23:46 +00:00
Steven R. Loomis
90f70b1cee ICU-2487 more warning cleanup, move a function out of public headers
X-SVN-Rev: 14999
2004-04-16 20:29:09 +00:00