/* only for Visual Stduio 2008 SP1 */ #define BOOST_REGEX_USE_CPP_LOCALE #include #include #include typedef unsigned int uint32_t; typedef std::basic_string u32string; typedef boost::basic_regex u32regex; typedef boost::match_results u32match; void put(const u32string& s) { for (size_t i = 0, n = s.size(); i < n; i++) { printf("%x, ", s[i]); } printf("\n"); } #if 1 namespace std { template<> bool ctype::is(std::ctype_base::mask m, uint32_t c) const { if (c & ~0xFFU) return false; // return use_facet >(std::locale()).is(m, static_cast(c)); #if 0 static struct Custom : public std::ctype { const mask * table() const { return std::ctype::table(); } } custom; static const mask* maskTbl = custom.table(); return (maskTbl[(unsigned char)c] & m) != 0; #else static const std::ctype& cache = use_facet >(std::locale()); return cache.is(m, static_cast(c)); #endif } template<> uint32_t ctype::tolower(uint32_t c) const { if ('A' <= c && c <= 'Z') return c - 'A' + 'a'; return c; } template<> uint32_t ctype::widen(char c) const { return c; } } #endif int main() { /* ‚±‚ê‚ÍUTF-8 */ const uint32_t str_[] = { 0x3053, 0x308c, 0x306f, 'U', 'T', 'F', '-', '8', 0 }; const uint32_t r_[] = { '\\', 'w', '+', 0 }; u32string str(str_); u32regex r(r_, boost::regex::icase); u32match m; if (boost::regex_search(str, m, r)) { put(m.str()); } else { puts("none"); } }