-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Locale deserialize 'zh-hant_CN' #1948
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
Comments
…{variant}_# | #){script}-{extensions}
I am not sure I really understand the intent here: for one, changing observed behavior in a patch is almost guaranteed break some usage somewhere. I can not do that without good justification. Locale instances have 3 pieces of information:
and the important part is that these parts get correctly split. Check should NOT be based on textual representation by But most of all... I am not sure I understand the problem being solved here. What exactly is wrong, and how is it being improved? |
case STD_LOCALE:
{
int ix = value.indexOf('_');
if (ix < 0) { // single argument
return new Locale(value);
}
String first = value.substring(0, ix);
value = value.substring(ix+1);
ix = value.indexOf('_');
if (ix < 0) { // two pieces
return new Locale(first, value);
}
String second = value.substring(0, ix);
return new Locale(first, second, value.substring(ix+1));
}
case STD_LOCALE:
{
int ix = _firstHyphenOrUnderscore(value);
if (ix < 0) { // single argument
return new Locale(value);
}
String first = value.substring(0, ix);
value = value.substring(ix+1);
ix = _firstHyphenOrUnderscore(value);
if (ix < 0) { // two pieces
return new Locale(first, value);
}
String second = value.substring(0, ix);
return new Locale(first, second, value.substring(ix+1));
}
protected int _firstHyphenOrUnderscore(String str)
{
for (int i = 0, end = str.length(); i < end; ++i) {
char c = str.charAt(i);
if (c == '_' || c == '-') {
return i;
}
}
return -1;
} Jackson serialize a most of system use the _ to split language, country, variant, like
|
config: System.setProperty("jackson.std.locale.de.java", "not empty")
commit #1951 so If use Java system (include andorid), we need a complete Java style deserialize Locale's String. Default is use |
I am not sure I understand, still. Older versions only accepted underscore ( Removing acceptance of hyphen would probably break existing usage so that can not be simply disabled. If logic for when one or both may be used is wrong we can improve it. We just need to agree on how logic should work; perhaps it should check separates from left to right? And for tests we need something better than simply writing out strings to compare: components decode should be tested for correctness. Not just read/write and verify round-trip (String value written is same as String value used as input), but that component, language deserialized matches |
Another possibility: JDK 1.7 has |
At this point I am not sure what expected handling would be; and I do not think proposed solution is correct. It is NOT correct to say that underscore ( Finally, I don't think Jackson 2.9 should change handling unless it can be guaranteed change does not break existing usage. |
zh-hant_CN
will convert tozh_HANT_cn
Locale include (language, country, variant), Locale.toString() use '_' to split then
{language}_{country}_({variant}_# | #){script}-{extensions}
but Jackson deserialize Locale use '-' or '_' : (
code: FromStringDeserializer.Std._deserialize
iana language-tags
rfc4647 language lookup
in jdk1.5 -> 1.8
others:
#1344
#1600
The text was updated successfully, but these errors were encountered: