Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Win32: implement further UTF8 support
[xestiacalendar/.git] / source / objects / calendarobject / CalendarObject.cpp
index 6cfe78b..76cb4e6 100644 (file)
@@ -26,15 +26,37 @@ CalendarObjectLoadResult CalendarObject::LoadFile(std::string loadFilename){
        // Check if the file exists and return 
        // CALENDAROBJECTLOAD_CANNOTOPEN if not.
        
-       if (!FileExists(loadFilename)){
-               return CALENDAROBJECTLOAD_MISSING;
-       }
-       
        ifstream fileStream;
        string receivedStringData = "";
        
+#ifndef WIN32
+
+       if (!FileExists(loadFilename)) {
+               return CALENDAROBJECTLOAD_MISSING;
+       }
+
        fileStream.open(loadFilename, ifstream::in);
-       
+
+#else
+
+       wstring loadFilename_utf16;
+
+       int len = MultiByteToWideChar(CP_UTF8, 0, &loadFilename[0], (int)loadFilename.size(), NULL, 0);
+
+       if (len > 0)
+       {
+               loadFilename_utf16.resize(len);
+               MultiByteToWideChar(CP_UTF8, 0, &loadFilename[0], (int)loadFilename.size(), &loadFilename_utf16[0], len);
+       }
+
+       if (!FileExists(loadFilename_utf16)) {
+               return CALENDAROBJECTLOAD_MISSING;
+       }
+
+       fileStream.open(loadFilename_utf16, ifstream::in);
+
+#endif
+
        if (fileStream.rdstate() & ifstream::failbit){
                return CALENDAROBJECTLOAD_CANNOTOPEN;
        }
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy