2011-07-24 20 views

回答

1

我猜它看起來有點像這樣:

std::string unescape(const std::string s) 
{ 
    std::string temp = boost::regex_replace(s, "%u(....)", "&#x$1;", boost::match_default); 
    temp = boost::regex_replace(temp, "%u(..)", "&#x$1;", boost::match_default); 
    return temp; 
} 

但我承擔.(DOT)應只匹配十六進制值,在這種情況下,我會去這樣的事情,而不是:

std::string unescape(const std::string s) 
{ 
    return boost::regex_replace(s, "%u([0-9a-fA-F]{2}|[0-9a-fA-F]{4})", "&#x$1;", 
           boost::match_default); 
} 

(請注意,我沒有測試這個!)

相關問題