File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -305,11 +305,12 @@ std::string type_name2type_identifier(const std::string &name)
305
305
};
306
306
const auto replace_invalid_characters_with_underscore =
307
307
[](const std::string &identifier) {
308
- static const std::regex non_alpha_numeric{" [^A-Za-z0-9]+" };
308
+ static const std::regex non_alpha_numeric{" [^A-Za-z0-9\x80 - \xff ]+" };
309
309
return std::regex_replace (identifier, non_alpha_numeric, " _" );
310
310
};
311
311
const auto strip_leading_non_letters = [](const std::string &identifier) {
312
- static const std::regex identifier_regex{" [A-Za-z][A-Za-z0-9_]*" };
312
+ static const std::regex identifier_regex{
313
+ " [A-Za-z\x80 -\xff ][A-Za-z0-9_\x80 -\xff ]*" };
313
314
std::smatch match_results;
314
315
bool found = std::regex_search (identifier, match_results, identifier_regex);
315
316
POSTCONDITION (found);
Original file line number Diff line number Diff line change @@ -63,3 +63,11 @@ TEST_CASE(
63
63
" 0123456789_banana_0123456789_split_0123456789" ) ==
64
64
" banana_0123456789_split_0123456789" );
65
65
}
66
+
67
+ TEST_CASE (
68
+ " type_name2type_identifier UTF-8 characters" ,
69
+ " [core][ansi-c][type_name2type_identifier]" )
70
+ {
71
+ const std::string utf8_example = " \xF0\x9F\x8D\x8C\xF0\x9F\x8D\xA8 " ;
72
+ CHECK (type_name2type_identifier (utf8_example) == utf8_example);
73
+ }
You can’t perform that action at this time.
0 commit comments