From a02d4adbecc4e24940d95e8f40b7d096c37017b2 Mon Sep 17 00:00:00 2001 From: naoto Date: Tue, 14 Feb 2017 13:20:48 -0800 Subject: [PATCH] 8174779: Locale issues with Mac 10.12 Reviewed-by: bchristi --- .../native/java/lang/java_props_macosx.c | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/solaris/native/java/lang/java_props_macosx.c b/src/solaris/native/java/lang/java_props_macosx.c index b43f290b0..8246b8130 100644 --- a/src/solaris/native/java/lang/java_props_macosx.c +++ b/src/solaris/native/java/lang/java_props_macosx.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -80,23 +80,31 @@ char *getMacOSXLocale(int cat) { // "en-GB" (language with alpha-2 region designator) // "es-419" (language with 3-digit UN M.49 area code) // "zh-Hans" (language with ISO 15924 script designator) + // "zh-Hans-US" (language with ISO 15924 script designator and region) + // "zh-Hans-419" (language with ISO 15924 script designator and UN M.49) // - // In the case of region designators (alpha-2 or UN M.49), we convert + // In the case of region designators (alpha-2 and/or UN M.49), we convert // to our locale string format by changing '-' to '_'. That is, if // the '-' is followed by fewer than 4 chars. char* scriptOrRegion = strchr(languageString, '-'); - if (scriptOrRegion != NULL && strlen(scriptOrRegion) < 5) { - *scriptOrRegion = '_'; - - assert((strlen(scriptOrRegion) == 3 && + if (scriptOrRegion != NULL) { + int length = strlen(scriptOrRegion); + if (length > 5) { + // Region and script both exist. Honor the script for now + scriptOrRegion[5] = '\0'; + } else if (length < 5) { + *scriptOrRegion = '_'; + + assert((length == 3 && // '-' followed by a 2 character region designator isalpha(scriptOrRegion[1]) && isalpha(scriptOrRegion[2])) || - (strlen(scriptOrRegion) == 4 && + (length == 4 && // '-' followed by a 3-digit UN M.49 area code isdigit(scriptOrRegion[1]) && isdigit(scriptOrRegion[2]) && isdigit(scriptOrRegion[3]))); + } } const char* retVal = languageString; -- GitLab