Solution to ogre failure to read Chinese paths

Source: Internet
Author: User

The following is the source code related to file operations in ogre.

Code Datastreamptr filesystemarchive: open ( Const String & Filename) Const
{
String full_path
= Concatenate_path (mname, filename );

// Use filesystem to determine size
// (Quicker than streaming to the end and back)
Struct Stat tagstat;
Int RET = Stat (full_path.c_str (), & Tagstat );
Assert (Ret
=   0   &&   " Problem getting File Size " );

//Always open in binary mode
STD: ifstream*Origstream=Ogre_new_t (STD: ifstream, memcategory_general )();
Origstream
->Open (full_path.c_str (), STD: IOS ::In |STD: IOS: Binary );

// Shocould check ensure open succeeded, in case fail for some reason.
If (Origstream -> Fail ())
{
Ogre_delete_t (origstream, basic_ifstream, memcategory_general );
Ogre_effect (exception: err_file_not_found,
" Cannot open file: "   + Filename,
" Filesystemarchive: Open " );
}

/// construct return stream, tell it to delete on destroy
filestreamdatastream * stream = ogre_new filestreamdatastream (filename,
origstream, tagstat. st_size,
true );
return datastreamptr (Stream);
}< br>

 

 

MainCodeYes

Origstream -> Open (full_path.c_str (), STD: IOS :: In   | STD: IOS: Binary );

 

 

Before opening a file in a file stream, set the language environment.

STD: locale :: Global (STD: locale ( "" ));

 

 

Next we found that the problem of Chinese path was solved,There is a problem when writing integer or floating point data to a file, such as "1000". After the output, it becomes "1,000"

This is because we changed the language environment. To minimize the modification, we should restore the previous settings after opening the file.

STD: locale savelocal = STD: locale :: Global (STD: locale ( "" ));
Origstream
-> Open (full_path.c_str (), STD: IOS :: In   | STD: IOS: Binary );
STD: locale ::
Global (Savelocal );

 

 

Everything is fine now ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.