[topic] URL特殊文字のエスケープ
Posted feedbacks - C++
cURLpp を使えば escape, unescape が用意されています。 curl が元になっているので [a-zA-Z0-9] 以外がエスケープされるようです。
see: cURLpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <cstdlib>
#include <iostream>
#include <curlpp/cURLpp.hpp>
using namespace std;
using namespace cURLpp;
int main ( int argc, char *argv[] ){
if( argc < 2 ){
return EXIT_FAILURE;
}
string escaped = cURLpp::escape( argv[1] );
cout << escaped << endl;
string unescaped = cURLpp::unescape( escaped );
cout << unescaped << endl;
return EXIT_SUCCESS;
}
|
ログイン忘れてました…。だけではなんなので、 少しだけ書き方を変えて短くしたものを。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include <cstdlib>
#include <iostream>
#include <curlpp/cURLpp.hpp>
using namespace std;
int main ( int argc, char *argv[] ){
if( argc < 2 ){
return EXIT_FAILURE;
}
string escaped, unescaped;
cout << (escaped = cURLpp::escape( argv[1] )) << endl;
cout << (unescaped = cURLpp::unescape( escaped )) << endl;
return EXIT_SUCCESS;
}
|





にしお
#4156()
Rating0/0=0.00
URL用に特殊な文字をエスケープする。
[ reply ]