Non-english file path problem

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Gregory
Just popping in
Just popping in
Posts: 2
Joined: Thu Jan 17, 2008 15:00

Non-english file path problem

Postby Gregory » Thu Jan 17, 2008 15:53

Hi guys,
I've got the following problem in my app (using MS Windows XP, VS2005, CEGUI v0.5.0):

I have a file-path that contains some non-English characters, like:

Code: Select all

std::wstring logPath = L"C:\\Project\\MyApp\\Мои Данные\\CEGUILog.txt";


and I want to set it during the creation of System object as my log file.

Code: Select all

CEGUI::String sLog = { here I call some subroutine that converts UTF16 to UTF8 (via WideCharToMultiByte), then I assign it}

new CEGUI::System(m_impl->m_renderer, 0, 0, 0, "", sLog);


and get the exception from the DefaultLogger::setLogFilename(..):
"Logger::setLogFilename - Failed to open file."

First of all, I thought there is something wrong with UTF16 -> UTF8 conversion, but i tried this routine to write non-English text on some CEGUI controls (buttons, listbox listitems, etc) and it seems everything is fine.

However, then I noticed that the DefaultLogger::setLogFilename calls d_ostream.open(filename.c_str(), ....) routine that expects the file-path to be ANSI.
But the filename.c_str() method call returns the UTF8 characters and the method fails..

Now I'm stuck =(

I would be grateful if somebody helped me to fix this..

Thanks

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Fri Jan 18, 2008 09:34

Hi,

I'm not sure what to suggest at the moment for an easy fix.

If you're not worried about portability you could probably modify the logger code to do something different (meaning using something from Win32 API or an MS extension to the std lib - maybe _wfopen or something).

I'm uncertain as to how to classify this issue at the moment. At the very least we should add some notes to the documentation to draw attention to this shortcoming.

User avatar
fezztah
Just popping in
Just popping in
Posts: 20
Joined: Wed Jun 20, 2007 14:50

Postby fezztah » Fri Jan 18, 2008 11:14

I was planning to use logging only in development and then disable it on release.

I suppose you could argue that the cegui log might be useful if a member of the public somehow triggered a problem, a hardware issue perhaps or maybe you were going to do a public beta test or were making a cegui based tool.


Code: Select all

class NullLogger : public CEGUI::Logger
{
public:
   NullLogger() : CEGUI::Logger() {};
   virtual void logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level = CEGUI::Standard) {};
   virtual void setLogFilename(const CEGUI::String& filename, bool append = false) {};
};

#ifdef FINAL
static NullLogger s_nullLogger;
#endif

Gregory
Just popping in
Just popping in
Posts: 2
Joined: Thu Jan 17, 2008 15:00

Postby Gregory » Fri Jan 18, 2008 18:08

Hi
Thank you for your response.

Agree with CrazyEddie - one of the possible solutions is to modify the source code and use the MS extension, something like:

Code: Select all

std::ifstream ifs(_wfopen(...));

But here I could inctroduce some bugs in the CEGUI and something could go wrong...

Disable the logging could be useful too, but I have the same problem if I try to set up a resource group directory

Code: Select all

rp->setResourceGroupDirectory(...)

and the file path I provide to this method contains some non-English characters -- I get the exception from DirectX9Renderer when I try to load a texture.

One of the solutions under MS Windows (without CEGUI modifications) could be to use HardLinks & Junctions (read Symbolic Links) which allows us to use multiple paths to refer to the same file.
( CreateHardLink & DeviceIoControl Win32 API functions) I tried this method and it works, but only with the NTFS...

Thank you all,
Gregory

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Mon Jan 21, 2008 07:27

Yeah, I don't think there is any simple solution that would fit for all scenarios. Obviously the use of international characters in file names is something that I hadn't tested (or even thought of), so this is all new to me :)

Feel free to post back what you eventually decide to do.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 40 guests