Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //not by me
- std::string toEscaped( std::string const& original )//<< utf8decode - use utf8_encode in PHP and get the normal string
- {
- std::string results ;
- for ( std::string::const_iterator iter = original.begin();
- iter != original.end();
- ++ iter ) {
- static bool const allowed[256];
- if ( allowed[static_cast<unsigned char>(*iter)] ) {
- results += *iter;
- } else {
- static char const hexChars[] = "0123456789ABCDEF";
- results += '%';
- results += hexChars[(*iter >> 4) & 0x0F];
- results += hexChars[(*iter ) & 0x0F];
- }
- }
- return results;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement