Commit 3cc7534a authored by bitplane's avatar bitplane

Bugfix for UTF8 filenames in file dialog, thanks to MadHyde for the patch [bug 2450094]

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2608 dfc29bdd-3216-0410-991c-e03cc46cb475
parent bb5627cf
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "IGUIFontBitmap.h" #include "IGUIFontBitmap.h"
#include "IFileList.h" #include "IFileList.h"
#include "os.h" #include "os.h"
#include <locale>
namespace irr namespace irr
{ {
...@@ -325,18 +326,39 @@ void CGUIFileOpenDialog::fillListBox() ...@@ -325,18 +326,39 @@ void CGUIFileOpenDialog::fillListBox()
FileList = FileSystem->createFileList(); FileList = FileSystem->createFileList();
core::stringw s; core::stringw s;
setlocale(LC_ALL,"");
if (FileList) if (FileList)
{ {
for (u32 i=0; i < FileList->getFileCount(); ++i) for (u32 i=0; i < FileList->getFileCount(); ++i)
{ {
s = FileList->getFileName(i); #ifndef _IRR_WCHAR_FILESYSTEM
const c8 *cs = (const c8 *)FileList->getFileName(i).c_str();
wchar_t *ws = new wchar_t[strlen(cs) + 1];
int len = mbstowcs(ws,cs,strlen(cs));
ws[len] = 0;
s = ws;
delete ws;
#else
s = FileList->getFileName(i).c_str();
#endif
FileBox->addItem(s.c_str(), skin->getIcon(FileList->isDirectory(i) ? EGDI_DIRECTORY : EGDI_FILE)); FileBox->addItem(s.c_str(), skin->getIcon(FileList->isDirectory(i) ? EGDI_DIRECTORY : EGDI_FILE));
} }
} }
if (FileNameText) if (FileNameText)
{ {
#ifndef _IRR_WCHAR_FILESYSTEM
const c8 *cs = (const c8 *)FileSystem->getWorkingDirectory().c_str();
wchar_t *ws = new wchar_t[strlen(cs) + 1];
int len = mbstowcs(ws,cs,strlen(cs));
ws[len] = 0;
s = ws;
delete ws;
#else
s = FileSystem->getWorkingDirectory(); s = FileSystem->getWorkingDirectory();
#endif
FileDirectory = s; FileDirectory = s;
FileNameText->setText(s.c_str()); FileNameText->setText(s.c_str());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment