Thanks Karlsson.
I just went through HDDFile.cpp and HDDDirectory.cpp and added code to convert between SystemCharset and UTF8. Piece of cake to find the right places in the code BECAUSE THOSE ARE ALL THE PLACES WHERE A SIMILAR CONVERSION IS DONE FOR WINDOWS ;-))).
Still wasn't doing anything. Turns out that XBMC is calling iconv and sets SystemCharset to "" in CharsetConverter.cpp:CConverterType::ResolveSpecialCharset, and any conversion from/to "" doesn't seem to be doing anything. So it seems to me that any CharsetConverter calls From/To System was so far a NOP. But there didn't seem to be much use of SystemCharset in the source anyhow. Are you aware of any actual functionality of SystemCharset on any system (maybe non-linux, non-windows ?).
I think the right solution would be to have a GUI config option to set the System Charset, but i didn't want to hack in that into code, so i just take SystemCharset from environment now.
On my linux system, with the diff below, nothing change unless you set environment variable XBMC_SYSTEM_CHARSET to eg: ISO-8859-15 before starting XBMC, and with that it my german umlauts work fine now.
Any chance to get a diff like this committed ? Given how it seems to be NOP unless you explicitly set the environment variable, i'd hope the risk is fairly low.
Cheers
-----------
diff -cr ../../../../my-portage/media-tv/xbmc-9999/work/xbmc/filesystem/HDDirectory.cpp ./xbmc/filesystem/HDDirectory.cpp
*** ../../../../my-portage/media-tv/xbmc-9999/work/xbmc/filesystem/HDDirectory.cpp 2014-01-19 18:54:22.000000000 +0100
--- ./xbmc/filesystem/HDDirectory.cpp 2014-01-20 22:06:08.315295000 +0100
***************
*** 20,25 ****
--- 20,26 ----
#include "HDDirectory.h"
#include "Util.h"
+ #include "utils/CharsetConverter.h"
#include "iso9660.h"
#include "URL.h"
#include "FileItem.h"
***************
*** 81,86 ****
--- 82,88 ----
strSearchMask += L"*.*";
#else
CStdString strSearchMask(strRoot);
+ g_charsetConverter.utf8ToSystem(strSearchMask);
#endif
FILETIME localTime;
***************
*** 100,106 ****
#ifdef TARGET_WINDOWS
g_charsetConverter.wToUTF8(wfd.cFileName,strLabel, true);
#else
! strLabel = wfd.cFileName;
#endif
if ( (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
{
--- 102,109 ----
#ifdef TARGET_WINDOWS
g_charsetConverter.wToUTF8(wfd.cFileName,strLabel, true);
#else
! // strLabel = wfd.cFileName;
! g_charsetConverter.systemToUtf8(wfd.cFileName, strLabel);
#endif
if ( (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
{
***************
*** 152,157 ****
--- 155,161 ----
return Exists(strPath); // A drive - we can't "create" a drive
if(::CreateDirectoryW(CWIN32Util::ConvertPathToWin32Form(strPath1).c_str(), NULL))
#else
+ g_charsetConverter.utf8ToSystem(strPath1);
if(::CreateDirectory(strPath1.c_str(), NULL))
#endif
return true;
***************
*** 163,185 ****
bool CHDDirectory::Remove(const char* strPath)
{
if (!strPath || !*strPath)
return false;
#ifdef TARGET_WINDOWS
return (::RemoveDirectoryW(CWIN32Util::ConvertPathToWin32Form(strPath).c_str()) || GetLastError() == ERROR_PATH_NOT_FOUND) ? true : false;
#else
! return ::RemoveDirectory(strPath) ? true : false;
#endif
}
bool CHDDirectory::Exists(const char* strPath)
{
if (!strPath || !*strPath)
return false;
#ifdef TARGET_WINDOWS
DWORD attributes = GetFileAttributesW(CWIN32Util::ConvertPathToWin32Form(strPath).c_str());
#else
! DWORD attributes = GetFileAttributes(strPath);
#endif
if(attributes == INVALID_FILE_ATTRIBUTES)
return false;
--- 167,195 ----
bool CHDDirectory::Remove(const char* strPath)
{
+ CStdString strPath1 = strPath;
+
if (!strPath || !*strPath)
return false;
#ifdef TARGET_WINDOWS
return (::RemoveDirectoryW(CWIN32Util::ConvertPathToWin32Form(strPath).c_str()) || GetLastError() == ERROR_PATH_NOT_FOUND) ? true : false;
#else
! g_charsetConverter.utf8ToSystem(strPath1);
! return ::RemoveDirectory(strPath1) ? true : false;
#endif
}
bool CHDDirectory::Exists(const char* strPath)
{
+ CStdString strPath1 = strPath;
+
if (!strPath || !*strPath)
return false;
#ifdef TARGET_WINDOWS
DWORD attributes = GetFileAttributesW(CWIN32Util::ConvertPathToWin32Form(strPath).c_str());
#else
! g_charsetConverter.utf8ToSystem(strPath1);
! DWORD attributes = GetFileAttributes(strPath1);
#endif
if(attributes == INVALID_FILE_ATTRIBUTES)
return false;
diff -cr ../../../../my-portage/media-tv/xbmc-9999/work/xbmc/filesystem/HDFile.cpp ./xbmc/filesystem/HDFile.cpp
*** ../../../../my-portage/media-tv/xbmc-9999/work/xbmc/filesystem/HDFile.cpp 2014-01-19 18:54:22.000000000 +0100
--- ./xbmc/filesystem/HDFile.cpp 2014-01-20 23:59:40.923295000 +0100
***************
*** 23,28 ****
--- 23,29 ----
#include "system.h"
#include "HDFile.h"
#include "Util.h"
+ #include "utils/CharsetConverter.h"
#include "URL.h"
#include "utils/AliasShortcutUtils.h"
#ifdef TARGET_POSIX
***************
*** 94,99 ****
--- 95,101 ----
#ifdef TARGET_WINDOWS
m_hFile.attach(CreateFileW(CWIN32Util::ConvertPathToWin32Form(strFile).c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL));
#else
+ g_charsetConverter.utf8ToSystem(strFile);
m_hFile.attach(CreateFile(strFile.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL));
#endif
if (!m_hFile.isValid()) return false;
***************
*** 117,122 ****
--- 119,125 ----
return true;
#else
struct __stat64 buffer;
+ g_charsetConverter.utf8ToSystem(strFile);
return (_stat64(strFile.c_str(), &buffer)==0);
#endif
}
***************
*** 164,169 ****
--- 167,173 ----
strWFile.pop_back();
return _wstat64(strWFile.c_str(), buffer);
#else
+ g_charsetConverter.utf8ToSystem(strFile);
return _stat64(strFile.c_str(), buffer);
#endif
}
***************
*** 187,192 ****
--- 191,197 ----
#ifdef TARGET_WINDOWS
m_hFile.attach(CreateFileW(CWIN32Util::ConvertPathToWin32Form(strPath).c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, bOverWrite ? CREATE_ALWAYS : OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL));
#else
+ g_charsetConverter.utf8ToSystem(strPath);
m_hFile.attach(CreateFile(strPath.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, bOverWrite ? CREATE_ALWAYS : OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL));
#endif
if (!m_hFile.isValid())
***************
*** 310,315 ****
--- 315,321 ----
#ifdef TARGET_WINDOWS
return :
eleteFileW(CWIN32Util::ConvertPathToWin32Form(strFile).c_str()) ? true : false;
#else
+ g_charsetConverter.utf8ToSystem(strFile);
return :
eleteFile(strFile.c_str()) ? true : false;
#endif
}
***************
*** 322,327 ****
--- 328,335 ----
#ifdef TARGET_WINDOWS
return ::MoveFileW(CWIN32Util::ConvertPathToWin32Form(strFile).c_str(), CWIN32Util::ConvertPathToWin32Form(strNewFile).c_str()) ? true : false;
#else
+ g_charsetConverter.utf8ToSystem(strFile);
+ g_charsetConverter.utf8ToSystem(strNewFile);
return ::MoveFile(strFile.c_str(), strNewFile.c_str()) ? true : false;
#endif
}
diff -cr ../../../../my-portage/media-tv/xbmc-9999/work/xbmc/utils/CharsetConverter.cpp ./xbmc/utils/CharsetConverter.cpp
*** ../../../../my-portage/media-tv/xbmc-9999/work/xbmc/utils/CharsetConverter.cpp 2014-01-19 18:54:22.000000000 +0100
--- ./xbmc/utils/CharsetConverter.cpp 2014-01-21 00:00:50.203540000 +0100
***************
*** 244,250 ****
switch (charset)
{
case SystemCharset:
! return "";
case UserCharset:
return g_langInfo.GetGuiCharSet();
case SubtitleCharset:
--- 244,254 ----
switch (charset)
{
case SystemCharset:
! {
! CStdString locale;
! locale = getenv("XBMC_SYSTEM_CHARSET");
! return locale ? locale : "";
! }
case UserCharset:
return g_langInfo.GetGuiCharSet();
case SubtitleCharset: