What can I do in order to make opencascade support chinese file path? Opencascade can not open file under chinese file path now .
Marko Knöbl Thu, 03/07/2013 - 16:43
I had this problem too. In order to work around it in my application I'm creating a temporary directory, then copying the file to that temporary directory and reading it from there.
On Linux I get a file path that looks like this: "/var/my-application-name/import-file.stp" - so it only contains ASCII characters and can be read without any problem.
Note that this workaround will not help if the users are running Windows and have non-ASCII-characters in their username as the temporary path there will be "C:\Users\USERNAME\AppData\Local\Temp\my-application-name".
Thanks for your help! I have tried you method but it also can not read chinese file path.
I checked opencascade's source file and found that it is the type OSD_Path that can not surpport
chinese characters. Because chinese character is multi-bytes and opencascade read file path with Standard_Character,So it can not read chinese character. I need change opencascade's code if I want
improve the problem.
It can be setteled by this way : in the file OSD_Path.cxx there is a function named systemname, change the code
for ( i = j = 1; i <= myTrek.UsefullLength() && j <= _MAX_PATH; ++i, ++j )
to
for ( i = j = 1; i <= myTrek.Length() && j <= _MAX_PATH; ++i, ++j )
Thu, 03/07/2013 - 16:43
I had this problem too. In order to work around it in my application I'm creating a temporary directory, then copying the file to that temporary directory and reading it from there.
On Linux I get a file path that looks like this: "/var/my-application-name/import-file.stp" - so it only contains ASCII characters and can be read without any problem.
Note that this workaround will not help if the users are running Windows and have non-ASCII-characters in their username as the temporary path there will be "C:\Users\USERNAME\AppData\Local\Temp\my-application-name".
Hope this helps!
Mon, 03/11/2013 - 14:23
If you use Windows, you might try to use the short path name, which if I remember correctly only consists of ascii letters:
wstring strStepFile = L"Some Chinese Name.stp"
char strFileName[_MAX_PATH];
wcstombs(strFileName, strStepFile.c_str(), _MAX_PATH);
if (strchr(strFileName, '?') != NULL)
{
wchar_t strShortPath[_MAX_PATH];
::GetShortPathNameW(strStepFile .c_str(), strShortPath,
_MAX_PATH);
wcstombs(strFileName, strShortPath, _MAX_PATH);
}
Mon, 03/11/2013 - 15:17
Thanks for your help! I have tried you method but it also can not read chinese file path.
I checked opencascade's source file and found that it is the type OSD_Path that can not surpport
chinese characters. Because chinese character is multi-bytes and opencascade read file path with Standard_Character,So it can not read chinese character. I need change opencascade's code if I want
improve the problem.
Tue, 03/12/2013 - 17:55
It can be setteled by this way : in the file OSD_Path.cxx there is a function named systemname, change the code
for ( i = j = 1; i <= myTrek.UsefullLength() && j <= _MAX_PATH; ++i, ++j )
to
for ( i = j = 1; i <= myTrek.Length() && j <= _MAX_PATH; ++i, ++j )
can rebuild the project,then it is oK!
Sat, 12/12/2015 - 14:05
Thanks for tips, but I can't see the changes you mentioned?
Could you explain clearly?
Fri, 12/18/2015 - 13:35
Convert the path string to UTF8
Wed, 12/23/2015 - 07:03
It works. Thank you so much!