OpenSceneGraph
OpenSceneGraph copied to clipboard
osgText::TextBase serialization errors when using osgText::String::ENCODING_UTF8
I'am use OpenSceneGraph 3.6.5 with Visual Studio 2015. Trying this code:
osg::ref_ptr<osgText::Text> text = new osgText::Text();
text->setText("тестовый текст", osgText::String::ENCODING_UTF8);
osgDB::writeNodeFile(*text, "d:/test.osgt");
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("d:/test.osgt");
Have console output:
AsciiInputIterator::readProperty(): Unmatched property osg::UIntArray, expecting ArrayID
Error reading file d:/test.osgt: read error (InputStream::readArray(): Unsupported array type. At osgText::TextBase )
binary format may work (osgb)
Not working too. I found this bug on binary osgb format and tested on osgt to view serialization data structure
maybe the string literial "тестовый текст" is compiled with your local code page, not utf-8. so when you call setText() function using osgText::String::ENCODING_UTF8, it cannot recognize the charactors
maybe the string literial "тестовый текст" is compiled with your local code page, not utf-8. so when you call setText() function using osgText::String::ENCODING_UTF8, it cannot recognize the charactors
I am have my source code in utf-8 code page. I am using ForceUTF8 Visual Studio extension for this
source code in utf-8 not means the string literial compiled in utf-8. You can use the /utf-8 option to specify both the source and execution character sets as encoded by using UTF-8. https://docs.microsoft.com/en-us/cpp/build/reference/utf-8-set-source-and-executable-character-sets-to-utf-8?view=vs-2019