coin3d / coin

Coin3D core library
BSD 3-Clause "New" or "Revised" License
285 stars 108 forks source link

SbString constructor for wide character pointers #68

Closed VolkerEnderlein closed 10 years ago

VolkerEnderlein commented 10 years ago

Original report by Thomas Moeller (Bitbucket: TheHubbit, GitHub: TheHubbit).


Starting with version 4 Coin3D uses UTF8 encoded strings. However, there is no method exposed by the SbString class that encodes a wide character string to UTF8. Also the included utility function cc_string_utf8_encode() only converts single characters and does not handle platform specific encoding of wide character strings (Linux: utf32, Windows: utf16).

In my opinion it would be very useful if the SbString class accepts also wide character strings, taking care of the conversion to UTF8. Please comment on this proposal. Would it be safe to assume that all targeted compilers support the wchar_t type now? I could implement this functionality if there are no concerns.

VolkerEnderlein commented 10 years ago

Original comment by Roy Walmsley (Bitbucket: walroy, GitHub: walroy).


Thomas,

Yes, I think that would be a good idea. But, before you embark on it, be sure to consider the downstream usage. After all, SbString is widespread in Coin.

Roy

VolkerEnderlein commented 10 years ago

Original comment by Thomas Moeller (Bitbucket: TheHubbit, GitHub: TheHubbit).


Roy, Thank you for commenting on this issue. Yes, I share your concerns regarding changes to the widely used SbString class. Because it is so central I tried to find out what the response of the other users would be. But so far not much objection or support.

I implemented the proposed extension and created pull request #198 for it. I pretty much tried to follow the approach taken so far (even though I'm not a big fan of the style in string.cpp). No new include statements have been added to the header files, which I fear could impact other components possibly even outside of Coin itself, such as SoQt.

Please let me know what you (or maybe others?) think.

Best, Thomas

VolkerEnderlein commented 10 years ago

Original comment by Roy Walmsley (Bitbucket: walroy, GitHub: walroy).


Merged pull request #198.