aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/sys
diff options
context:
space:
mode:
authorPatrik Nyblom <[email protected]>2010-10-13 17:08:32 +0200
committerPatrik Nyblom <[email protected]>2010-11-29 13:59:12 +0100
commit4cf08709189ea8b7e2ae20f85c390abd04ae48ae (patch)
treeb9a1ee11e1672e03d8a80a0b8829bdaab75f66bf /erts/emulator/sys
parent25e22145d129a80dcfc02c64dfe0b0d890a5e26d (diff)
downloadotp-4cf08709189ea8b7e2ae20f85c390abd04ae48ae.tar.gz
otp-4cf08709189ea8b7e2ae20f85c390abd04ae48ae.tar.bz2
otp-4cf08709189ea8b7e2ae20f85c390abd04ae48ae.zip
Teach filename to accept raw data and add filename enc option to emu
Diffstat (limited to 'erts/emulator/sys')
-rw-r--r--erts/emulator/sys/common/erl_sys_common_misc.c52
1 files changed, 35 insertions, 17 deletions
diff --git a/erts/emulator/sys/common/erl_sys_common_misc.c b/erts/emulator/sys/common/erl_sys_common_misc.c
index dbb59676c8..581c14b6c6 100644
--- a/erts/emulator/sys/common/erl_sys_common_misc.c
+++ b/erts/emulator/sys/common/erl_sys_common_misc.c
@@ -42,33 +42,51 @@
/* Written once and only once */
static int filename_encoding = ERL_FILENAME_UNKNOWN;
+#if defined(__WIN32__)
+static int user_filename_encoding = ERL_FILENAME_UTF8; /* Default unicode on windows */
+#else
+static int user_filename_encoding = ERL_FILENAME_LATIN1;
+#endif
+void erts_set_user_requested_filename_encoding(int encoding)
+{
+ user_filename_encoding = encoding;
+}
+
+int erts_get_user_requested_filename_encoding(void)
+{
+ return user_filename_encoding;
+}
void erts_init_sys_common_misc(void)
{
#if defined(__WIN32__)
filename_encoding = ERL_FILENAME_WIN_WCHAR;
#else
- char *l;
- filename_encoding = ERL_FILENAME_LATIN1;
+ if (user_filename_encoding != ERL_FILENAME_UNKNOWN) {
+ filename_encoding = user_filename_encoding;
+ } else {
+ char *l;
+ filename_encoding = ERL_FILENAME_LATIN1;
# ifdef PRIMITIVE_UTF8_CHECK
- setlocale(LC_CTYPE, ""); /* Set international environment,
- ignore result */
- if (((l = getenv("LC_ALL")) && *l) ||
- ((l = getenv("LC_CTYPE")) && *l) ||
- ((l = getenv("LANG")) && *l)) {
- if (strstr(l, "UTF-8")) {
- filename_encoding = ERL_FILENAME_UTF8;
- }
- }
-
+ setlocale(LC_CTYPE, ""); /* Set international environment,
+ ignore result */
+ if (((l = getenv("LC_ALL")) && *l) ||
+ ((l = getenv("LC_CTYPE")) && *l) ||
+ ((l = getenv("LANG")) && *l)) {
+ if (strstr(l, "UTF-8")) {
+ filename_encoding = ERL_FILENAME_UTF8;
+ }
+ }
+
# else
- l = setlocale(LC_CTYPE, ""); /* Set international environment */
- if (l != NULL) {
- if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0) {
- filename_encoding = ERL_FILENAME_UTF8;
+ l = setlocale(LC_CTYPE, ""); /* Set international environment */
+ if (l != NULL) {
+ if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0) {
+ filename_encoding = ERL_FILENAME_UTF8;
+ }
}
- }
# endif
+ }
#endif
}