Revision: 2377
          http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2377&view=rev
Author:   rorthomas
Date:     2012-01-28 16:00:51 +0000 (Sat, 28 Jan 2012)
Log Message:
-----------
hacky fix character conversion problems under linux

Modified Paths:
--------------
    trunk/source/main/utils/utils.cpp

Modified: trunk/source/main/utils/utils.cpp
===================================================================
--- trunk/source/main/utils/utils.cpp   2012-01-28 15:19:04 UTC (rev 2376)
+++ trunk/source/main/utils/utils.cpp   2012-01-28 16:00:51 UTC (rev 2377)
@@ -288,22 +288,35 @@
        delete[] tmpBuff;
        return ret;
 #else
+       // TODO: GET THIS WORKING
        /*
        const char* srcPtr = _source.c_str();
-       iconv_t i = iconv_open("UTF-8", "ANSI");
-       if ( i == (iconv_t) -1 ) return wstring();
+       iconv_t icv = iconv_open("ASCII", "UTF-8");
+       if ( icv == (iconv_t) -1 )
+       {
+               return std::wstring(L"ERR1");
+       }
 
-       char * smile = "263a";  // the smile sign unicode
-       size_t inbytes = sizeof (smile);
+       char *inpbuf    = const_cast<char *>(_source.c_str());
+       size_t inbytes  = _source.size();
        size_t outbytes = inbytes;
-       size_t nread=0;
-       char ** outbuf = (char **)malloc(outbytes+1);
+       size_t nread    = 0;
+       char *outbuf    = (char *)calloc((outbytes*4+1)*sizeof(char), 1);
 
-       MultiByteToWideChar( CP_ACP, 0, srcPtr, -1, tmpBuff, tmpSize );
-       std::wstring ret = tmpBuff;
-       delete[] tmpBuff;
+       size_t res = iconv(icv, &inpbuf, &inbytes, &outbuf, &outbytes); 
+       if(res == (size_t) -1)
+       {
+               //free(outbuf);
+               return std::wstring(L"ERR2");
+       }
+       iconv_close(icv);
+       //free(outbuf);
        */
-       return std::wstring();
+
+       // hacky!
+       std::wstring str2(_source.length(), L' '); // Make room for characters
+       std::copy(_source.begin(), _source.end(), str2.begin());
+       return str2;
 #endif // WIN32
 }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel

Reply via email to