1 개요[ | ]
- EncodeURIComponent() - JavaScript
- rawurlencode() - PHP
입력값 | 출력값 |
---|---|
(space) |
%20
|
% |
%25
|
/ |
%2F
|
2 Bash[ | ]
Python 활용
Python
Copy
input='hello 123 http://zetawiki.com 한글'
output=`python -c "import urllib; print urllib.quote('''$input''', '')"`
echo $output
# hello%20123%20http%3A%2F%2Fzetawiki.com%20%ED%95%9C%EA%B8%80
PHP 활용
Bash
Copy
input='hello 123 http://zetawiki.com 한글'
output=`php -r "echo rawurlencode('$input');"`
echo $output
# hello%20123%20http%3A%2F%2Fzetawiki.com%20%ED%95%9C%EA%B8%80
3 Java[ | ]

Java
Copy
String input = "hello 123 http://zetawiki.com 한글";
System.out.println(URLEncoder.encode(input, "UTF-8").replace("*", "%2A").replace("+", "%20").replace("%7E", "~"));
// hello%20123%20http%3A%2F%2Fzetawiki.com%20%ED%95%9C%EA%B8%80
4 JavaScript[ | ]

JavaScript
Copy
console.log( encodeURIComponent("hello 123 http://zetawiki.com 한글") );
// hello%20123%20http%3A%2F%2Fzetawiki.com%20%ED%95%9C%EA%B8%80
JavaScript
Copy
console.log( encodeURIComponent("개요") );
// %EA%B0%9C%EC%9A%94
JavaScript
Copy
console.log( encodeURIComponent("hello") );
// hello
JavaScript
Copy
console.log( encodeURIComponent("%UserProfile%") );
// %25UserProfile%25
5 PHP[ | ]

PHP
Copy
$input='hello 123 http://zetawiki.com 한글';
echo rawurlencode($input);
// hello%20123%20http%3A%2F%2Fzetawiki.com%20%ED%95%9C%EA%B8%80
6 Python[ | ]
Python
Copy
# -*- coding: utf-8 -*-
import urllib
input = 'hello 123 http://zetawiki.com 한글'
print urllib.quote(input, '')
# hello%20123%20http%3A%2F%2Fzetawiki.com%20%ED%95%9C%EA%B8%80
7 같이 보기[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.