如何解决如何在 gettext-runtime\intl\printf.c 中启用 HAVE_FWPRINTF?
我正在尝试在 Windows 系统上返回区域设置名称。为此,我需要在代码中使用 swprintf(),如下所示。
#include <wchar.h>
#include <shlwapi.h>
#include <langinfo.h>
...
/* Construct the full name of the locale. E.g. "en-US" to
* "English_United States".
*/
static char *
construct_full_locale_name(wchar_t *locale_name)
{
char result[FULL_LOCALE_NAME_LENGTH * 2];
wchar_t wc_full_locale_name[FULL_LOCALE_NAME_LENGTH];
wchar_t buffer[LOCALE_NAME_MAX_LENGTH];
size_t len;
wmemset(wc_full_locale_name,LOCALE_NAME_MAX_LENGTH);
/*
* Construct the full name of the locale using GetLocaleInfoEx API by using
* a few specific flags in the following order. First,if the locale is
* valid,we will get the language name in English by using
* LOCALE_SENGLISHLANGUAGENAME flag. If the locale is invalid we can't get
* anything so we are returning the locale name as it is. Once the locale
* is verified,we can proceed to get region using
* LOCALE_SENGLISHCOUNTRYNAME flag. In the same way,we will get code-page
* using LOCALE_IDEFAULTANSICODEPAGE.
*/
if (GetLocaleInfoEx(locale_name,LOCALE_SENGLISHLANGUAGENAME,(LPWSTR)&buffer,LOCALE_NAME_MAX_LENGTH))
{
int cp;
len = swprintf(wc_full_locale_name,LOCALE_NAME_MAX_LENGTH,L"%ls",buffer);
wmemset(buffer,LOCALE_NAME_MAX_LENGTH);
GetLocaleInfoEx(locale_name,LOCALE_SENGLISHCOUNTRYNAME,LOCALE_NAME_MAX_LENGTH);
len += swprintf(wc_full_locale_name + len,LOCALE_NAME_MAX_LENGTH - len,L"_%ls",buffer);
GetLocaleInfoEx(locale_name,LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,(LPWSTR)&cp,sizeof(cp) / sizeof(WCHAR));
swprintf(wc_full_locale_name + len,FULL_LOCALE_NAME_LENGTH - len,L".%u",cp);
/*wchar2char() is internally defined function to turn wide-char to char */
wchar2char(result,wc_full_locale_name,sizeof(wc_full_locale_name),NULL);
}
sprintf(result,"%s",locale_messages);
return result;
}
这里的问题是,当我在其他系统上构建此代码时,我在运行时遇到错误 libintl_swprintf 未找到。经过一番调查,我发现这个符号与 libintl.h 相关。
#undef swprintf
#define swprintf libintl_swprintf
extern LIBINTL_DLL_EXPORTED int swprintf (wchar_t *,size_t,const wchar_t *,...);
该函数定义在 gettext-runtime\intl\printf.c
...
#if HAVE_FWPRINTF
...
DLL_EXPORTED
int
libintl_swprintf (wchar_t *resultbuf,size_t length,const wchar_t *format,...)
{
va_list args;
int retval;
va_start (args,format);
retval = libintl_vswprintf (resultbuf,length,format,args);
va_end (args);
return retval;
}
#endif
#endif
此功能由HAVE_FWPRINTF控制,我在gettext代码中找不到它的定义位置,有人可以帮助如何启用它吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。