Bug #6751
std::isalpha(foo, std::locale::classic()) depends on current locale
Status:
Rejected
Priority:
Normal
Assignee:
-
Category:
locale - data and messages
Start date:
2016-03-15
Due date:
% Done:
0%
Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Description
std::locale::classic() is apparently supposed to always use the "C" locale, but it appears not to be the case:
kekkonen ~ % cat alpha.cc
#include <cctype>
#include <locale>
#include <stdio.h>
int main(void) {
setlocale(LC_ALL, "");
printf("is alpha: %d\n", (std::isalpha((char)0xe4, std::locale::classic()) ? 1 : 0));
return 0;
}
kekkonen ~ % g++ -o alpha alpha.cc
kekkonen ~ % LC_CTYPE=C ./alpha
is alpha: 0
kekkonen ~ % LC_CTYPE=fi_FI.ISO8859-15 ./alpha
is alpha: 1
On Linux this returns 0 regardless of locale.
http://en.cppreference.com/w/cpp/locale/locale/classic
https://github.com/rakshasa/rtorrent/pull/159#issuecomment-196716419
History
Updated by Lauri Tirkkonen about 4 years ago
Apparently the same as https://www.illumos.org/issues/4173 (I failed to find that with search somehow)