From 84f62e6ff2e1ac37e412ddf7c06d3ceb985e2ee3 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 11 May 2016 09:49:45 +0100 Subject: Use C++ locale based functions instead of the libc ones --- src/unicode.hh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/unicode.hh') diff --git a/src/unicode.hh b/src/unicode.hh index 9b65e265..83c63fa1 100644 --- a/src/unicode.hh +++ b/src/unicode.hh @@ -2,6 +2,7 @@ #define unicode_hh_INCLUDED #include +#include namespace Kakoune { @@ -28,7 +29,7 @@ enum WordType { Word, WORD }; template inline bool is_word(Codepoint c) { - return c == '_' or iswalnum(c); + return c == '_' or std::isalnum((wchar_t)c, std::locale{}); } template<> @@ -67,8 +68,8 @@ inline CharCategories categorize(Codepoint c) return 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 Codepoint to_lower(Codepoint cp) { return std::tolower((wchar_t)cp, std::locale{}); } +inline Codepoint to_upper(Codepoint cp) { return std::toupper((wchar_t)cp, std::locale{}); } 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; } -- cgit v1.2.3