Search code examples
androidunicodec++11android-ndkutf-16

u16string and char16_t in Android NDK


I wish to create (std::getline()) and manipulate UTF-16 strings in the Android NDK, so that I can pass them (relatively) painlessly back to Java for display. Currently, I'm using C++0x, using the LOCAL_CPPFLAGS := -std=c++0x switch, which works (I'm using some other 0x functions). Seems the compiler can't find u16string. I've included <string>, and get no other errors. I wish to do something such as:


ifstream file(fileName);
if(!file.is_open()) {
    return false;
}
while(!file.eof()) {
    u16string fileLine;
    std::getline(file, fileLine);

    // Do stuff with fileLine
}
return true;

Does the NDK include an out-of-date version of GCC or something? What should I do?


Solution

  • The NDK does not (at least not officially) support wide characters, UTF-16 or anything like that. Nor does it provide a proper C++ library.