Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics

How can opencascade support chinese file path ?

How can opencascade support chinese file path ?
SunHongLei 2013/03/07 12:10
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 2013/03/07 13: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!
Göran Barz 2013/03/11 11: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,
wcstombs(strFileName, strShortPath, _MAX_PATH);
SunHongLei 2013/03/11 12: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.
SunHongLei 2013/03/12 14: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 )
for ( i = j = 1; i <= myTrek.Length() && j <= _MAX_PATH; ++i, ++j )

can rebuild the project,then it is oK!
Latest news
  • Open CASCADE CAD Assistant for iOS platform is available!
  • Open CASCADE Technology 6.9.0 is available for download!
  • JT Assistant for Android

  • © OPEN CASCADE 2000 - 2015  |  Search  |  Contacts   |  Site map