< prev index next >
src/java.instrument/unix/native/libinstrument/EncodingSupport_md.c
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2018, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -61,11 +61,11 @@
* Initialize all utf processing.
*/
static void
utfInitialize(void)
{
- char *codeset;
+ const char* codeset;
/* Set the locale from the environment */
(void)setlocale(LC_ALL, "");
/* Get the codeset name */
@@ -75,10 +75,24 @@
return;
}
UTF_DEBUG(("Codeset = %s\n", codeset));
+#ifdef MACOSX
+ /* On Mac, if US-ASCII, but with no env hints, use UTF-8 */
+ const char* env_lang = getenv("LANG");
+ const char* env_lc_all = getenv("LC_ALL");
+ const char* env_lc_ctype = getenv("LC_CTYPE");
+
+ if (strcmp(codeset,"US-ASCII") == 0 &&
+ (env_lang == NULL || strlen(env_lang) == 0) &&
+ (env_lc_all == NULL || strlen(env_lc_all) == 0) &&
+ (env_lc_ctype == NULL || strlen(env_lc_ctype) == 0)) {
+ codeset = "UTF-8";
+ }
+#endif
+
/* If we don't need this, skip it */
if (strcmp(codeset, "UTF-8") == 0 || strcmp(codeset, "utf8") == 0 ) {
UTF_DEBUG(("NO iconv() being used because it is not needed\n"));
return;
}
@@ -144,10 +158,11 @@
output[outputLen] = 0;
return outputLen;
}
/* Failed to do the conversion */
+ UTF_DEBUG(("iconv() failed to do the conversion\n"));
return -1;
}
/* Just copy bytes */
outputLen = len;
< prev index next >