std::locale::global(std::locale(""))和工程属性中的字符集有什么区别?

gldcpp 2017-01-09 09:27:40
这二者存在冲突情况么?例如工程字符集为unicode而后在代码中又使用了 std::locale::global(std::locale("chs"));,这会对先前为unicode字符集的工程的字符相关处理产生影响么?
...全文
652 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
justwannafuckyou 2017-01-12
  • 打赏
  • 举报
回复
引用 3 楼 ID870177103 的回复:
工程的字符集仅用于_UNICODE宏是否定义 一些头文件会根据是否定义_UNICODE而使用不同的代码 比如说windows的TEXT宏和TCHAR locale用于C标准stdlib.h中一些运行时转换格式的函数,c++的库大部分类似函数其实也是依赖它 setlocale会改变整个进程的设置,大概是c时代随意定义static变量留下来的锅 这要求你不要改来改去 推荐MSVC的_create_locale扩展
解释的很到位!
赵4老师 2017-01-10
  • 打赏
  • 举报
回复
提醒楼主:这些词汇对应的函数都是开源的。 Locale Use the setlocale function to change or query some or all of the current program locale information. “Locale” refers to the locality (the country and language) for which you can customize certain aspects of your program. Some locale-dependent categories include the formatting of dates and the display format for monetary values. For more information, see Locale Categories. Locale-Dependent Routines Routine Use setlocale Category Setting Dependence atof, atoi, atol Convert character to floating-point, integer, or long integer value, respectively LC_NUMERIC is Routines Test given integer for particular condition. LC_CTYPE isleadbyte Test for lead byte () LC_CTYPE localeconv Read appropriate values for formatting numeric quantities LC_MONETARY, LC_NUMERIC MB_CUR_MAX Maximum length in bytes of any multibyte character in current locale (macro defined in STDLIB.H) LC_CTYPE _mbccpy Copy one multibyte character LC_CTYPE _mbclen Return length, in bytes, of given multibyte character LC_CTYPE mblen Validate and return number of bytes in multibyte character LC_CTYPE _mbstrlen For multibyte-character strings: validate each character in string; return string length LC_CTYPE mbstowcs Convert sequence of multibyte characters to corresponding sequence of wide characters LC_CTYPE mbtowc Convert multibyte character to corresponding wide character LC_CTYPE printf functions Write formatted output LC_NUMERIC (determines radix character output) scanf functions Read formatted input LC_NUMERIC (determines radix character recognition) setlocale, _wsetlocale Select locale for program Not applicable strcoll, wcscoll Compare characters of two strings LC_COLLATE _stricoll, _wcsicoll Compare characters of two strings (case insensitive) LC_COLLATE _strncoll, _wcsncoll Compare first n characters of two strings LC_COLLATE _strnicoll, _wcsnicoll Compare first n characters of two strings (case insensitive) LC_COLLATE strftime, wcsftime Format date and time value according to supplied format argument LC_TIME _strlwr Convert, in place, each uppercase letter in given string to lowercase LC_CTYPE strtod, wcstod, strtol, wcstol, strtoul, wcstoul Convert character string to double, long, or unsigned long value LC_NUMERIC (determines radix character recognition) _strupr Convert, in place, each lowercase letter in string to uppercase LC_CTYPE strxfrm, wcsxfrm Transform string into collated form according to locale LC_COLLATE tolower, towlower Convert given character to corresponding lowercase character LC_CTYPE toupper, towupper Convert given character to corresponding uppercase letter LC_CTYPE wcstombs Convert sequence of wide characters to corresponding sequence of multibyte characters LC_CTYPE wctomb Convert wide character to corresponding multibyte character LC_CTYPE _wtoi, _wtol Convert wide-character string to int or long LC_NUMERIC
ID870177103 2017-01-10
  • 打赏
  • 举报
回复
工程的字符集仅用于_UNICODE宏是否定义 一些头文件会根据是否定义_UNICODE而使用不同的代码 比如说windows的TEXT宏和TCHAR locale用于C标准stdlib.h中一些运行时转换格式的函数,c++的库大部分类似函数其实也是依赖它 setlocale会改变整个进程的设置,大概是c时代随意定义static变量留下来的锅 这要求你不要改来改去 推荐MSVC的_create_locale扩展

65,187

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧