diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-11-11 00:21:20 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-11-11 00:21:20 +0000 |
| commit | 892c3647e44b98d5edf8ba0e92a67b68aa2e57c6 (patch) | |
| tree | b048b12335d3655efc1538cc53854ddef2fab0e8 /src/unicode.hh | |
| parent | 7bd3f4306ddb030d6f7c70f3bcb0fa4e9b6ac4b4 (diff) | |
Fix to_lower/to_upper handling to correctly support non unicode chars
require a proper unicode locale setup on the system
Fixes #94
Diffstat (limited to 'src/unicode.hh')
| -rw-r--r-- | src/unicode.hh | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/unicode.hh b/src/unicode.hh index b74ebcfc..37f3541b 100644 --- a/src/unicode.hh +++ b/src/unicode.hh @@ -63,6 +63,12 @@ inline CharCategories categorize(Codepoint c) : CharCategories::Punctuation; } +inline Codepoint to_lower(Codepoint cp) { return towlower((wchar_t)cp); } +inline Codepoint to_upper(Codepoint cp) { return towupper((wchar_t)cp); } + +inline char to_lower(char c) { return c >= 'A' and c <= 'Z' ? c - 'A' + 'a' : c; } +inline char to_upper(char c) { return c >= 'a' and c <= 'z' ? c - 'a' + 'A' : c; } + } #endif // unicode_hh_INCLUDED |
