Last active
December 16, 2015 00:39
-
-
Save rmartinho/5349044 to your computer and use it in GitHub Desktop.
Testing the claims from http://stackoverflow.com/a/11255698/46642
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ locale | |
LANG=en_US.UTF-8 | |
LC_CTYPE=en_US.UTF-8 | |
LC_NUMERIC="en_US.UTF-8" | |
LC_TIME="en_US.UTF-8" | |
LC_COLLATE="en_US.UTF-8" | |
LC_MONETARY="en_US.UTF-8" | |
LC_MESSAGES="en_US.UTF-8" | |
LC_PAPER="en_US.UTF-8" | |
LC_NAME="en_US.UTF-8" | |
LC_ADDRESS="en_US.UTF-8" | |
LC_TELEPHONE="en_US.UTF-8" | |
LC_MEASUREMENT="en_US.UTF-8" | |
LC_IDENTIFICATION="en_US.UTF-8" | |
LC_ALL= | |
$ clang++ -v | |
clang version 3.2 (tags/RELEASE_32/final) | |
Target: x86_64-pc-linux-gnu | |
Thread model: posix | |
$ clang++ -stdlib=c++11 -stdlib=libc++ -xc++ -o test - <<END | |
> #include <locale> | |
> #include <regex> | |
> #include <iostream> | |
> #include <cassert> | |
> int main() { | |
> std::locale::global(std::locale("en_US.UTF-8")); | |
> | |
> std::regex pattern1("[[:alpha:]]", std::regex_constants::extended); | |
> std::cout << std::boolalpha << std::regex_match(std::string("\xC3\xA9"), pattern1) << '\n'; | |
> std::regex pattern2("[[:alpha:]]+", std::regex_constants::extended); | |
> std::cout << std::boolalpha << std::regex_match(std::string("abcd\xC3\xA9" "fg"), pattern2) << '\n'; | |
> std::regex pattern3("..", std::regex_constants::extended); | |
> std::cout << std::boolalpha << std::regex_match(std::string("\xC3\xA9"), pattern3) << '\n'; | |
> } | |
> END | |
$ ./test | |
false | |
false | |
true | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment