함수 encodeURIComponent()

(함수 rawurlencode()에서 넘어옴)

1 개요[ | ]

EncodeURIComponent() - JavaScript
rawurlencode() - PHP
입력값 출력값
(space) %20
% %25
/ %2F

2 Bash[ | ]

Python 활용
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 활용
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[ | ]

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[ | ]

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

5 PHP[ | ]

$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[ | ]

# -*- 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 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}