1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-23 03:21:55 +03:00
kakoune/src/regex.cc
Maxime Coste abac6a9436 Use boost::wregex implementation and manually utf8 decode into it
That way we get proper unicode support in regular expressions as long
as the current locale treats wchar_t as unicode codepoints.

Fixes #638
Fixes #595
Fixes #162
2016-05-10 09:38:21 +01:00

25 lines
458 B
C++

#include "regex.hh"
#include "exception.hh"
namespace Kakoune
{
using Utf8It = RegexUtf8It<const char*>;
Regex::Regex(StringView re, flag_type flags) try
: boost::wregex{Utf8It{re.begin(), re}, Utf8It{re.end(), re}}, m_str(re.str())
{} catch (std::runtime_error& err) { throw regex_error(err.what()); }
String option_to_string(const Regex& re)
{
return re.str();
}
void option_from_string(StringView str, Regex& re)
{
re = Regex{str};
}
}