问题
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 char
s and wchar_t
s. (But it requires a locale object)
来源:https://stackoverflow.com/questions/4396050/isupper-and-islower-for-wstring