2
\$\begingroup\$

I was working with the OGRE .NET bindings (MOGRE) for quite a long time. To improve my (not that good) C++ skills, I am switching from C# to C++.

After implementing a basic OGRE application, I was curious why Ogre has it's own String class Ogre::String? Why is it used and not std:string?

Can/shall I mix these String types and what shall I use in my OGRE application for non-OGRE tasks/methods?

\$\endgroup\$
5
\$\begingroup\$

Frameworks in C++ tend to use their own string implementation to solve Unicode and localization issues. Unicode support in C++ is generally not that good even in C++11. std::string can't store Unicode characters.

If you want to take advantage of unicode and probably localization you may want to use their string.

\$\endgroup\$
  • \$\begingroup\$ Thank you for that useful information. In this case, I will use the OGRE string implementation in my project. \$\endgroup\$ – einherjer Apr 16 '14 at 9:12
  • \$\begingroup\$ What exactly makes you say that the C++11 string implementation isn't good for unicode? std::string will store almost any unicode character, especially with the advent of u u8 and U. On windows you might have to use std::wstring though. \$\endgroup\$ – CoffeeandCode Apr 16 '14 at 14:35
  • \$\begingroup\$ @CoffeeandCode the reasons are summerized here stackoverflow.com/questions/17103925/… \$\endgroup\$ – concept3d Apr 16 '14 at 14:45
  • 3
    \$\begingroup\$ std::string does not store Unicode characters. It stores 8-bit codepoints. Those codepoints might happen to be valid UTF-8, but that's neither here nor there. The Standard library has basically zero support for Unicode. \$\endgroup\$ – DeadMG Apr 16 '14 at 20:01
  • 1
    \$\begingroup\$ Yes it does, just because it doesn't treat them as so doesn't mean that it doesn't. If you use the ICU library, you have to read all unicode strings into an std::string before decoding them with the library. AGAIN I wasn't referring to managing the strings in a standard std::string \$\endgroup\$ – CoffeeandCode Apr 17 '14 at 2:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.