Show
Ignore:
Timestamp:
02/24/10 11:52:51 (4 years ago)
Author:
mplatings
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgPlugins/fbx/ReaderWriterFBX.cpp

    r11109 r11110  
    2727#include "WriterNodeVisitor.h" 
    2828 
     29#if defined(WIN32) && !defined(__CYGWIN__) 
     30#define WIN32_LEAN_AND_MEAN 
     31//For MultiByteToWideChar 
     32#include <Windows.h> 
     33#endif 
     34 
     35// This function belongs in osgDB. Delete this function and use the osgDB 
     36// version once Robert accepts the submission. 
     37std::string convertStringFromCurrentCodePageToUTF8(const std::string& str) 
     38{ 
     39#if defined(WIN32) && !defined(__CYGWIN__) 
     40        if (str.length() == 0) 
     41        { 
     42                return std::string(); 
     43        } 
     44 
     45        int utf16Length = MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length(), 0, 0); 
     46        if (utf16Length <= 0) 
     47        { 
     48                osg::notify(osg::WARN) << "Cannot convert multi-byte string to UTF-8." << std::endl; 
     49                return std::string(); 
     50        } 
     51 
     52        std::wstring sUTF16(utf16Length, L'\0'); 
     53        utf16Length = MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length(), &sUTF16[0], utf16Length); 
     54        if (utf16Length <= 0) 
     55        { 
     56                osg::notify(osg::WARN) << "Cannot convert multi-byte string to UTF-8." << std::endl; 
     57                return std::string(); 
     58        } 
     59 
     60        return osgDB::convertUTF16toUTF8(sUTF16); 
     61#else 
     62        return str; 
     63#endif 
     64} 
    2965 
    3066/// Returns true if the given node is a basic root group with no special information. 
     
    145181        const std::string& utf8filename(filename); 
    146182#else 
    147         std::string utf8filename(osgDB::convertStringFromCurrentCodePageToUTF8(filename)); 
     183        std::string utf8filename(convertStringFromCurrentCodePageToUTF8(filename)); 
    148184#endif 
    149185 
     
    371407        // The FBX SDK interprets the filename as UTF-8 
    372408#ifdef OSG_USE_UTF8_FILENAME 
    373         std::string utf8filename(filename); 
     409        const std::string& utf8filename(filename); 
    374410#else 
    375         std::string utf8filename(osgDB::convertStringFromCurrentCodePageToUTF8(filename)); 
     411        std::string utf8filename(convertStringFromCurrentCodePageToUTF8(filename)); 
    376412#endif 
    377413