I already searched the forum, just to find hundreds of entries with "UNICODE", but not a single one about logfiles.
I'm working in a windows environment, where I want to store the logfiles within the directory %APPDATA%\MyApplication.
This works pretty well, as long as the username doesn't contain unicode characters.
I already tried receiving the target directory with 'SHGetFolderPathW(0, CSIDL_APPDATA, 0, SHGFP_TYPE_CURRENT, temppath);' and then converting it to an UTF-8 string, but this obviousy doesn't work, too.
The problem is, that std::ofstream takes its filename either as std::string (which obviously won't work with unicode characters in the path) or as std::wstring, which isn't supported by CEGUI::String.
I followed a few discussions concerning compatibility between CEGUI::String and std::wstring, but wouldn't it make sense at least to offer an alternative DefaultLogger::setLogFilename, taking an std::wstring?
Regards
- Mark
Another UNICODE issue
Moderators: CEGUI MVP, CEGUI Team
Re: Another UNICODE issue
As far as I know, CE has no intentions of supporting wchar_t or wstring. Anyway, windows already provides facilities for converting from multibyte to wide character, so you should not have any trouble converting to wstring. As far as the logger is concerned, you can easily derive a class from the DefaultLogger and add your own version of setLogFilename that takes a wstring parameter.
If you want CEGUI to support wchar_t/wstring natively then you will need provide an argument strong enough to convince CE to spend the time to implement it; or, you could implement it yourself and then contribute your work back to CEGUI
If you want CEGUI to support wchar_t/wstring natively then you will need provide an argument strong enough to convince CE to spend the time to implement it; or, you could implement it yourself and then contribute your work back to CEGUI
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!
Re: Another UNICODE issue
I think that CEGUI should at least have support for unicode filenames on Windows. Yes, users can derive their own classes, but since unicode support is such a key requirement nowadays, this functionality should really be part of the CEGUI library.
Function arguments could still use CEGUI::String, but whenever there's stuff stuff like opening files, in Windows environment it would do the conversion to UTF-16. For example in the case of setLogFilename it could be something like this:
Of course this is just for MSVC, and I have absolutely no idea about other windows compilers...
Function arguments could still use CEGUI::String, but whenever there's stuff stuff like opening files, in Windows environment it would do the conversion to UTF-16. For example in the case of setLogFilename it could be something like this:
Code: Select all
#ifdef _MSC_VER
std::wstring utf16filename = ConvertFromUTF32ToUTF16(filename); //Implement a conversion function in the String class or use MultiByteToWideChar() or whatever.
d_ostream.open(utf16filename.c_str(), std::ios_base::out | (append ? std::ios_base::app : std::ios_base::trunc));
#else
d_ostream.open(filename.c_str(), std::ios_base::out | (append ? std::ios_base::app : std::ios_base::trunc));
#endif
Of course this is just for MSVC, and I have absolutely no idea about other windows compilers...
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Another UNICODE issue
I wish you guys would post version information. This support (for international chars in filenames) was added for the DefaultResourceProvider on 20th February (so it's in branches/v0-7, trunk and the snapshots). If this support is not working, is this a bug report, then?
I hope you guys now see the importance of posting the version of the code you're using
CE.
I hope you guys now see the importance of posting the version of the code you're using
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Another UNICODE issue
I'm using the trunk version from 10/06/21, Rev #2567
Manually checking the DefaultResourceProvider, I found out, that Unicode support is implemented there (did not look into it before, as I didn't have a problem with that so far)
However, it's missing in the DefaultLogger Module.
Patch follows:
Manually checking the DefaultResourceProvider, I found out, that Unicode support is implemented there (did not look into it before, as I didn't have a problem with that so far)
However, it's missing in the DefaultLogger Module.
Patch follows:
Code: Select all
diff --git a/cegui/src/CEGUIDefaultLogger.cpp b/cegui/src/CEGUIDefaultLogger.cpp
index f4b0ec1..f443806 100644
--- a/cegui/src/CEGUIDefaultLogger.cpp
+++ b/cegui/src/CEGUIDefaultLogger.cpp
@@ -31,6 +31,8 @@
#include <ctime>
#include <iomanip>
+std::wstring Utf8ToUtf16(const std::string& utf8text);
+
// Start of CEGUI namespace section
namespace CEGUI
{
@@ -143,7 +145,11 @@ namespace CEGUI
d_ostream.close();
}
+#if defined(__WIN32__) || defined(_WIN32)
+ d_ostream.open(Utf8ToUtf16(filename.c_str()).c_str(), std::ios_base::out | (append ? std::ios_base::app : std::ios_base::trunc));
+#else
d_ostream.open(filename.c_str(), std::ios_base::out | (append ? std::ios_base::app : std::ios_base::trunc));
+#endif
if (!d_ostream)
{
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Another UNICODE issue
Ah, I actually failed to notice your post did actually mention the logger - speed reading FTW! ... or not!
Thanks for the other info and patch. I'll take a look sometime over the coming weekend.
CE.
Thanks for the other info and patch. I'll take a look sometime over the coming weekend.
CE.
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Another UNICODE issue
I'm afraid to wake up this old thread.
But has the problem ever been dealt with? I'm using CEGUI 0.7.5 on Windows 7 and I still get the issue and the patch doesn't seem to be applied if I look at my CEGUI sources.
Do I have to implement my almost exact copy of the default logger then?
But has the problem ever been dealt with? I'm using CEGUI 0.7.5 on Windows 7 and I still get the issue and the patch doesn't seem to be applied if I look at my CEGUI sources.
Do I have to implement my almost exact copy of the default logger then?
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Another UNICODE issue
I'm not sure what happened over that weekend, but if you say the change is not in, then I appear to have forgotten this.
I have added a ticket so that it's less likely to get lost in the future: http://www.cegui.org.uk/mantis/view.php?id=444
Thanks for the reminder
CE
I have added a ticket so that it's less likely to get lost in the future: http://www.cegui.org.uk/mantis/view.php?id=444
Thanks for the reminder
CE
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Re: Another UNICODE issue
Thanks for taking care of it. And I see you've also had a look at my ticket about throwing a C-String in the very same class.
- CrazyEddie
- CEGUI Project Lead
- Posts: 6760
- Joined: Wed Jan 12, 2005 12:06
- Location: England
- Contact:
Re: Another UNICODE issue
I see you've also had a look at my ticket about throwing a C-String in the very same class.
Yeah, I saw that. It's a left-over from a time when i) We did not use std::exception either directly or as a base class, and ii) CEGUI::Exception always attempted to write to the log - preventing the use of CEGUI::Exception anywhere before / during Logger construction. Neither of these points are still true, so the exception throw will get updated for 0.8.0.
CE
Useful Links: Forum Guidelines | Documentation | Tutorials | HOWTO | Videos | Donate to CEGUI | CEGUI Twitter
Return to “Bug Reports, Suggestions, Feature Requests”
Who is online
Users browsing this forum: No registered users and 1 guest