ogre에서 중국어 경로를 읽을 수 없는 해결 방법
1931 단어 중국어
코드
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);
// Should check ensure open succeeded, in case fail for some reason.
if (origStream->fail())
{
OGRE_DELETE_T(origStream, basic_ifstream, MEMCATEGORY_GENERAL);
OGRE_EXCEPT(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);
}
주요 코드는
origStream->open(full_path.c_str(), std::ios::in | std::ios::binary);
파일 흐름에서 파일을 열기 전에 언어 환경을 설정합니다
std::locale::global(std::locale(""));
다음에 우리는 중국어 경로의 문제가 해결되었지만 파일에 정형이나 부동점형 데이터를 쓸 때 문제가 있다는 것을 발견했다. 예를 들어'1000'이 출력된 후에'1000'이 되었다.
이것은 바로 우리가 언어 환경을 바꾸었기 때문이다. 수정을 최소화하기 위해서, 우리는 파일을 연 후에 이전의 설정을 복원해야 한다
std::locale saveLocal = std::locale::global(std::locale(""));
origStream->open(full_path.c_str(), std::ios::in | std::ios::binary);
std::locale::global(saveLocal);
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Java 정규가 중국어와 일치하는 방법 실례 분석본고는 자바의 정규가 중국어와 일치하는 방법을 실례로 기술하였다.다음과 같이 여러분에게 참고할 수 있도록 공유합니다. 1. 큰따옴표 사이의 내용과 일치: 2. 중국어 내용도 일치: 3, 구두점도 일치: 위의 세 프로...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.