-
Bug
-
Resolution: Fixed
-
P4
-
None
-
b97
-
generic
-
generic
-
Verified
Locale.toString()'s Javadoc states:
Returns a string representation of this Locale object, consisting of language, country, variant, script, and extensions as below:
language + "_" + country + "_" + (variant + "_#" | "#") + script + "-" + extensions
and one of its examples is:
zh_TW_#Hant-x-java
Both of these are incorrect from a reading of the code. The separator between script and extensions is "_", not "-".
The behavior of the code actually makes some sense to me -- as using "_" would seem to make it a bit easier to parse the result if you need to. In any case, the code or the Javadoc should be corrected -- one or the other.
All that said, the lack of any utility to do this parsing makes preserving script and extension information embedded in Locale.toString() output a dubious proposition. That's rather unfortunate given existing code that treated Locale.toString() output as a robust interchange representation of Locale objects.
I have read and understood the Javadoc about this -- and agree that the language tag format is a better, more standardized interchange format. Still, the lack of an API to robustly roundtrip Locale.toString() output back to fully equivalent Locale objects is rather unfortunate -- given where it leaves existing code.
Returns a string representation of this Locale object, consisting of language, country, variant, script, and extensions as below:
language + "_" + country + "_" + (variant + "_#" | "#") + script + "-" + extensions
and one of its examples is:
zh_TW_#Hant-x-java
Both of these are incorrect from a reading of the code. The separator between script and extensions is "_", not "-".
The behavior of the code actually makes some sense to me -- as using "_" would seem to make it a bit easier to parse the result if you need to. In any case, the code or the Javadoc should be corrected -- one or the other.
All that said, the lack of any utility to do this parsing makes preserving script and extension information embedded in Locale.toString() output a dubious proposition. That's rather unfortunate given existing code that treated Locale.toString() output as a robust interchange representation of Locale objects.
I have read and understood the Javadoc about this -- and agree that the language tag format is a better, more standardized interchange format. Still, the lack of an API to robustly roundtrip Locale.toString() output back to fully equivalent Locale objects is rather unfortunate -- given where it leaves existing code.