Hi Michael et. al,

On Tue, Oct 7, 2008 at 6:58 PM, Michael Platings
<[EMAIL PROTECTED]> wrote:
> My solution:
> - Add a OSG_USE_UTF8_FILENAMES option to CMake
> - let the user store all filenames in UTF-8 using
> osg::ConvertUTF16toUTF8()
> - where a file is loaded, if OSG_USE_UTF8_FILENAMES is true then convert
> the filename to UTF-16 using osg::ConvertUTF8toUTF16() and use a wide
> character function to open the file e.g. _wfopen instead of fopen.

Just for a little clarification of the proposed solution, the code
affected is primarily opening files using ofstream, ifstream or the C
fopen(), and  will look like...

>From Shader.cpp:

    std::ifstream sourceFile;
    sourceFile.open(OSG_STRING_TO_FILENAME(fileName).c_str(), std::ios::binary);

>From ReaderWriterOSG.cpp:

     std::ifstream fin(OSG_STRING_TO_FILENAME(fileName).c_str());

>From 3ds/file.cpp

      f=OSG_fopen(filename, "rb");

>From rgb/ReaderWriterRGB.cpp:

     std::ofstream fout(OSG_STRING_TO_FILENAME(fileName).c_str(),
std::ios::out | std::ios::binary);

The actual code submission has a few extra #ifdef too, the line
changes themselves aren't drastic, but they are widespread (67 changed
files in the submission).

My hope with widenning the discussion out to osg-users we'll be able
to get ideals on how to streamline the required changes futher, and if
possible make them less intrusive.  It might be that we need to change
all 67 files, but unless we solve this problem elegantly it's a
problem that will keep on haunting us as new submission come in a
break the above types of usage.

Off the top of my head my first suggestions, perhaps naive, would be
to have a osgDB::ifstream and osgDB::ofstream implementations that
take std::string (or alternatively) as parameters for the constructors
and open() and hide the traditional methods, and have these subclasses
do the internal conversions required.  An osgDB::fopen() could also be
written.

Thoughts?
Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to