isupper and islower for wstring

老子叫甜甜 提交于 2021-01-28 07:07:53

问题


I have a std::wstring and I want to find which character are upper case and which ones are lowercase. the std::isupper and islower seems to work on ASCII characters only but I want to be able to find out all kinds of uppercase and lowercase characters

e.g. á is an "Latin small letter a with acute" and Á is an "Latin capital letter A with acute" similarly ä and Ä are lower and upper case german letters.

Is there any function (mfc, boost or in any other library) which I can use to find out if a character is lower or upper case (irrespective of the locale)?

Thanks in advance

Rahul


回答1:


Most implementations are going to provide iswXxx functions, i.e. iswupper and iswlower. The big problem is that the encoding used in wide character strings is undefined and therefore which values are determined as upper and lower case are really up to the target platform. (Note that the iswXxx functions are not in the standard)

EDIT: And Bill is an idiot! The template declared in <locale> for std::isupper accepts both chars and wchar_ts. (But it requires a locale object)



来源:https://stackoverflow.com/questions/4396050/isupper-and-islower-for-wstring

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!