How to process non-latin letters with ODA IFC SDK?

  1. FAQ
  2. »
  3. IFC

String data within IFC is always in UTF-8 format, so when you get string using getAttr, the string is in UTF-8, and when you putAttr a string, SDK assumes the string is in UTF-8 format. Such UTF-8 data is implicitly converted into so-called Control Directives ('\X\C4\X\EF\X\EA\X\DC\X\F1\X\E9\X\E1') when writing Step Physical File, and converted from Control Directives into UTF-8 when reading Step Physical File.

 

UTF-8 -> putAttr -> writeFile -> Control Directives -> readFile -> getAttr -> UTF-8

 

So when you are working with string data, OdString and OdAnsiString can be used in pair for conversions:

 

OdString wStr("АБВГДЕЁ");
OdAnsiString ansiStr(wStr, OdCodePageId::CP_UTF_8);
inst->putAttr("string_value", ansiStr); // or inst->putAttr("string_value", ansiStr.c_str());
_writeSpf(model, "file.ifc"); // .ifc file will contain ansiStr data converted into internal representation (Control Directives) of such strings
...
_readSpf("file.ifc", model);
inst->getAttr("stringValue") >> ansiStr; // UTF-8 string with original data
OdString wStr(ansiStr, CP_UTF_8); // WChar string