diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index 0453c7068..2fd76e053 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -58,13 +58,17 @@ static char *utf8_convert(const char *filename){ size_t inbyteleft = MAX_PATH_SIZE, outbyteleft = MAX_PATH_SIZE; iconv_t cb; - strncpy(db_file_locale, filename, MAX_PATH_SIZE-1); - cb = iconv_open("UTF-8", nl_langinfo(CODESET)); - if(cb != (iconv_t)-1) { - int ret; - ret = iconv(cb, &inbuf, &inbyteleft, &outbuf, &outbyteleft); - if(ret == -1) db_file_utf8[0] = '\0'; - iconv_close(cb); + if (strcasecmp("UTF-8", nl_langinfo(CODESET)) == 0) { + strncpy(db_file_utf8, filename, MAX_PATH_SIZE - 1); + } else { + strncpy(db_file_locale, filename, MAX_PATH_SIZE-1); + cb = iconv_open("UTF-8", nl_langinfo(CODESET)); + if (cb != (iconv_t)-1) { + int ret; + ret = iconv(cb, &inbuf, &inbyteleft, &outbuf, &outbyteleft); + if(ret == -1) db_file_utf8[0] = '\0'; + iconv_close(cb); + } } #endif return ms_strdup(db_file_utf8); diff --git a/coreapi/sqlite3_bctbx_vfs.c b/coreapi/sqlite3_bctbx_vfs.c index efd6405dd..fac5a6ad2 100755 --- a/coreapi/sqlite3_bctbx_vfs.c +++ b/coreapi/sqlite3_bctbx_vfs.c @@ -260,7 +260,7 @@ static char* ConvertFromUtf8Filename(const char* fName){ bctbx_free(wideFilename); return convertedFilename; #elif defined(__QNXNTO__) - return bctbx_strdup(fName); + return bctbx_strdup(fName); #else #define MAX_PATH_SIZE 1024 char db_file_utf8[MAX_PATH_SIZE] = {'\0'}; @@ -269,13 +269,17 @@ static char* ConvertFromUtf8Filename(const char* fName){ size_t inbyteleft = MAX_PATH_SIZE, outbyteleft = MAX_PATH_SIZE; iconv_t cb; - strncpy(db_file_utf8, fName, MAX_PATH_SIZE-1); - cb = iconv_open(nl_langinfo(CODESET), "UTF-8"); - if(cb != (iconv_t)-1) { - int ret; - ret = iconv(cb, &inbuf, &inbyteleft, &outbuf, &outbyteleft); - if(ret == -1) db_file_locale[0] = '\0'; - iconv_close(cb); + if (strcasecmp("UTF-8", nl_langinfo(CODESET)) == 0) { + strncpy(db_file_locale, fName, MAX_PATH_SIZE - 1); + } else { + strncpy(db_file_utf8, fName, MAX_PATH_SIZE-1); + cb = iconv_open(nl_langinfo(CODESET), "UTF-8"); + if (cb != (iconv_t)-1) { + int ret; + ret = iconv(cb, &inbuf, &inbyteleft, &outbuf, &outbyteleft); + if(ret == -1) db_file_locale[0] = '\0'; + iconv_close(cb); + } } return bctbx_strdup(db_file_locale); #endif