Thu, 09/15/2011 - 17:12
Hi everybody,
I'm in charge of the development of an application based on Opencascade in C++. I have to translate this one for our russian users. So I have to use the UNICODE to manage cyrillic characters. No problem with my app in general, but the issue is when I want to use OCC : for exemple, OCC do not recognize such a character for the path and the file name in the case of a STEP import. The function ReadFile (STEPCAFControl_Reader or STEPControl_Reader) needs a Standard_CString in input. The conversion of the CString type and the Standard_CString in UNICODE returns only the first character of the CString :
CString sText = L"D:\дырпзураывма\миваидрупрдумдлдд\китпщки.step"; (with Unicode project) gives in with Occ "D".
Please someone did that ?! Please help me, I have tried many conversion method for one week... Thank you very much
Thu, 09/15/2011 - 20:40
Hello, you cannot mix up wide characters and chars. Your string L"foobar" is an array of wide characters (either 16 or 32 bits), and you cast it into char*. In my example, the first character "f" takes one byte, so the 2nd one (and 3rd and 4th if sizeof(wchar_t) is 4) is 0, and string length is 1. On a big endian machine, string would be seen as empty.
If you have to use CString, you must convert to/from UTF-8 (or any other encoding which fits your need).