OpenSceneGraph icon indicating copy to clipboard operation
OpenSceneGraph copied to clipboard

osgText::TextBase serialization errors when using osgText::String::ENCODING_UTF8

Open vvint opened this issue 4 years ago • 5 comments

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 )

vvint avatar Mar 31 '20 12:03 vvint

binary format may work (osgb)

mp3butcher avatar Apr 10 '20 12:04 mp3butcher

Not working too. I found this bug on binary osgb format and tested on osgt to view serialization data structure

vvint avatar Apr 10 '20 12:04 vvint

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

Haojia521 avatar May 31 '20 04:05 Haojia521

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

vvint avatar Jun 01 '20 07:06 vvint

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

Haojia521 avatar Jun 01 '20 08:06 Haojia521