forked from mirrors/linphone-iphone
Fix iconv conversion from UTF8 to UTF8 on Android and possibly others
This commit is contained in:
parent
297f63c7da
commit
2e086ee415
2 changed files with 23 additions and 15 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue