[Boost-bugs] [Boost C++ Libraries] #10383: Wrongly character was replaced when using boost::regex

Subject: [Boost-bugs] [Boost C++ Libraries] #10383: Wrongly character was replaced when using boost::regex
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-08-20 09:49:06


#10383: Wrongly character was replaced when using boost::regex
------------------------------+-------------------------
 Reporter: tamber@… | Owner: johnmaddock
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: regex
  Version: Boost 1.48.0 | Severity: Problem
 Keywords: regex replace |
------------------------------+-------------------------
 Hi,
 When I used regex_replace function to replace whitespace character in one
 string, I found that another character(0xa0 in memory) was also replaced.

 The follow is my verification code:

 int main(int argc, _TCHAR* argv[])
 {
     boost::regex whitespace_re("\\s+");
     string instr = "a c d f";
     cout << "Before replace instr:" << instr << endl;
     instr = boost::regex_replace(instr, whitespace_re, "-");
     cout << "After replaced instr: " << instr << endl;

     string instr2 = "abcdef";
     instr2[0]= 0xa0;
     instr2[2]= 0xa0;
     cout << "Before replace instr2:" << instr2 << endl;
     instr2 = boost::regex_replace(instr2, whitespace_re, "-");
     cout << "After replaced instr2: " << instr2 << endl;
     return 0;
 }

 And the output is attached.
 Develop Environment:
 Windows 7 Professional(language is Einglish U.S.), VS2005.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10383>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC