Skip to content

Instantly share code, notes, and snippets.

@rmartinho
Last active December 16, 2015 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmartinho/5349044 to your computer and use it in GitHub Desktop.
Save rmartinho/5349044 to your computer and use it in GitHub Desktop.
$ 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