Solution for missing std::wstring support in Android NDK?

后端 未结 3 1218
清酒与你
清酒与你 2021-01-13 11:58

I have a game which uses std::wstring as its basic string type in thousand of places as well as doing operations with wchar_t and its functions: wcsicmp() wcslen() vsprintf(

相关标签:
3条回答
  • 2021-01-13 12:31

    Try out CrystaX's NDK. It has had stl support long before the official google one. The current version (r5), which is based off the of the official ndk r5, is still beta 3, but it does have wchar_t support.

    http://www.crystax.net/android/ndk-r5.php

    0 讨论(0)
  • 2021-01-13 12:47

    I'm suffering from the same problem as you, but my only other thought is to load the strings via the JNI (as jstring* in native land), then convert them to UTF characters as necessary. Take a look at the available JNI string functions here:
    http://download.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html#string_operations

    0 讨论(0)
  • 2021-01-13 12:48

    Qt provides an excellent copy-on-write, international-friendly string implementation, QString, that is LGPLed.

    You could, in theory extract it from the Qt source and use it in your own project. You will find the QString implementation in src/corelib/tools/qstring.h and .cpp in a Qt source download. You would also need the QChar, QByteArray, QAtomic, and QNamespace includes/classes (all under the corelib folder,) and you should define QT_NO_STL_WCHAR when compiling. (For this I would compile by hand or using my own script/Makefile.) Not simple, but once you get it up and running your life will be a lot simpler. It's better than reinventing the wheel, because it comes with loads of convenience functions and features.

    Rather than stripping out just QString, you could also just use the QtCore module as a whole. See the android-lighthouse project for a Qt port to Android. (Also, it might be better to get your sources from there than from the above "vanilla" link, regardless of what you do.)

    0 讨论(0)
提交回复
热议问题