仅在 Xcode 中(visual studio 很好),如果您尝试使用 va_args 将其放入包装函数中,我会看到 swprintf 中断。
简化示例:
void test( wchar_t *a_buffer, int a_buffer_size, const wchar_t* a_format, ...)
{
va_list args;
va_start(args, a_format);
::swprintf(a_buffer, a_buffer_size, a_format, args );
va_end(args);
}
double value = 1.0;
wchar_t text[32];
::swprintf( text, 32, L"%f", value ); // this works (text=L"1.0000")
test(text, 32, L"%f", 30.0); // this does not work (text=L"0.0000")
任何帮助表示赞赏,这真是太麻烦了。我假设问题出在 XCode 的一些怪癖上。
我已经按照这个问题的建议弄乱了区域设置和文件属性:swprintf 在 xcode 中出现 unicode 字符失败,但在 Visual Studio 中工作但没有产生任何变化,它看起来像一个单独的问题。
谢谢。