std::string title = "中文";
NSString* str = [[NSString alloc] initWithFormat: @"test 中文 %s", title.c_str()]; // test 中文 ‰∏≠Êñá
I will get messy code. Can't I use %s
to insert chinese in iOS ? How can I get correct result.
The real scene is the nativeLog.
void nativeLog2(std::string format, va_list args)
{
NSString* str = [[NSString alloc] initWithFormat: [[NSString alloc] initWithUTF8String:format.c_str()] arguments:args];
NSLog(str);
}
void nativeLog(std::string format, ...)
{
va_list args;
va_start(args, format);
nativeLog2(format, args);
va_end(args);
}
std::string title = "中文";
nativeLog("test 中文 %s", title.c_str()); // test 中文 ‰∏≠Êñá