<i18n dev> Integrated: JDK-6285888: ChoiceFormat can support unescaped relational symbols in the Format segment

Justin Lu jlu at openjdk.org
Thu Feb 1 22:24:08 UTC 2024


On Tue, 30 Jan 2024 21:19:27 GMT, Justin Lu <jlu at openjdk.org> wrote:

> Please review this PR and [CSR](https://bugs.openjdk.org/browse/JDK-8314822) which allows for the _Format_ segment of a ChoiceFormat pattern to use the ChoiceFormat Relational symbols without the need to escape them using quotes. Previously, using a non escaped Relational symbol within a _Format_ segment would throw an IAE.
> 
> Implementation wise, this can be achieved by adding an additional check of `part == 0` to the relational symbol conditional. This is safe to do, as any subsequent relational symbols should only come after a '|' is parsed, which sets part back to 0. This ensures that for the duration of `part = 1` (Format segment), the relational symbols can be used without syntactic meaning.
> 
> For example, this change allows behavior such as: `new ChoiceFormat("1#The code is #7281")`. Previously, the workaround would have been new `ChoiceFormat("1#The code is '#'7281")` to achieve the same formatted behavior. Please see the CSR for more detail.
> 
> Additionally, this change also includes an unrelated grouping of the ChoiceFormat examples under a single header: **Usage Information**.

This pull request has now been integrated.

Changeset: d3c3194a
Author:    Justin Lu <jlu at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/d3c3194ac343a0e754448cd337f64114760de50b
Stats:     209 lines in 3 files changed: 144 ins; 56 del; 9 mod

6285888: ChoiceFormat can support unescaped relational symbols in the Format segment

Reviewed-by: naoto

-------------

PR: https://git.openjdk.org/jdk/pull/17640


More information about the i18n-dev mailing list