Does Android not really have wchar_t?

前端 未结 2 1275
被撕碎了的回忆
被撕碎了的回忆 2021-01-05 05:58

I built a simple method like below

wchar_t buf[1024] = {};
void logDebugInfo(wchar_t* fmt, ...)
{  
    va_list args;
    va_start(args, fmt);
    vswprintf(         


        
2条回答
  •  醉梦人生
    2021-01-05 06:56

    This is a bit old, but I've hit this while searching for a solution.
    It seems that the NDK (r8d for me) is still not supporting wsprintf: see issue and code.

    In my case I am using libjson (considering switching to yajl) for iOS/Android shared native code.
    Until I'll switch libraries, my workaround for NDK is this:

    double value = 0.5; // for example
    std::wstringstream wss;
    wss << value;
    return json_string(wss.str());
    

    I've read that streams are slower than the C functions, and if you need a pure C (and not C++) solution it doesn't help, but maybe someone will find this useful.

提交回复
热议问题