Search code examples
c++c

Is there any C/C++ system() function accepting unicode?


Question: In C/C++, is there any system function that accepts Unicode ? See below for reason:

#include <stdio.h>
#include <stdlib.h>


int main(int argc, char* argv[])
{
    // http://stackoverflow.com/questions/3313332/bringing-another-apps-window-to-front-on-mac-in-c
    system("osascript -e \"tell application \\\"Address Book\\\" to activate\"");
    return EXIT_SUCCESS;
}

Solution

  • system() does not care about the encoding as far as I know, it should just pass it through.

    maybe your question is "how to type a UTF-8 string literal in C", or "what encoding does osascript expect"?

    the portable way to do UTF-8 in C is with \x escape sequences, though if you are willing to rely on C99 or a specific compiler you can often type the UTF-8 directly.

    I would guess osascript expects UTF-8 though I have no real idea.