escape_encodeURI_encodeURLComponent

수정

escape, encodeURI, encodeURIComponent 인코딩 함수 비교

javascript의 escape, encodeURI, encodeURIComponent 인코딩 함수의 동작을 비교합니다.

escape

escape("!_한글, Hangul_!")
>> "%21_%uD55C%uAE00%2C%20Hangul_%21"
unescape("%21_%uD55C%uAE00%2C%20Hangul_%21")
>>ㄴ "!_한글, Hangul_!"

encodeURI

encodeURI("https://tistory.com/_hangul한글!")
>> "https://tistory.com/_hangul%ED%95%9C%EA%B8%80!"
decodeURI("https://tistory.com/_hangul%ED%95%9C%EA%B8%80!")
>> "https://tistory.com/_hangul한글!"

encodeURIComponent

encodeURIComponent("https://tistory.com/#_hangul한글!")
>> "https%3A%2F%2Ftistory.com%2F%23_hangul%ED%95%9C%EA%B8%80!"
decodeURIComponent("https%3A%2F%2Ftistory.com%2F%23_hangul%ED%95%9C%EA%B8%80!")
>> "https://tistory.com/#_hangul한글!"

escape, encodeURI, encodeURIComponent 사용 용도 비교

Reference

서재에서 보기 →