escape-unescape

escape, unescape

  • ํƒˆ์ถœ, ๋„ํ”ผ, ๋ชจ๋ฉด

  • ๋ญ”๊ฐ€๋ฅผ ํ”ผํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•œ๋‹ค๊ณ  ๋ณผ ์ˆ˜ ์žˆ์„๋“ฏ.

์„ค๋ช…

  • ํŠน์ • ๋ฌธ์ž๋Š” ํŠน์ˆ˜ํ•œ ๊ธฐ๋Šฅ์œผ๋กœ ์‚ฌ์šฉํ•˜๊ฒ ๋‹ค๊ณ  ์•ฝ์† ๋˜์–ด์žˆ์Œ

  • ์˜ˆ๋ฅผ ๋“ค๋ฉด ์›น์—์„œ๋Š” URL, http://a.com?name=egoing&job=programmer&job=programmer ์—์„œ ๋ณด๋ฉด, & ๋ฌธ์ž๋Š” ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๊ตฌ๋ถ„ํ•˜๋Š”๋ฐ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Œ.

  • ๊ทธ๋Ÿฐ๋ฐ http://a.com?name=egoing&job=programmer&blogger ์ด๋Ÿฐ ํ˜•์‹์˜ URL์ด ์˜จ๋‹ค๋ฉด? programmer&blogger ์—์„œ ์‚ฌ์šฉ๋œ & ํŠน์ˆ˜ํ•œ ๊ธฐ๋Šฅ์„ ๋ชฉ์ ์œผ๋กœ ์‚ฌ์šฉ๋œ ๊ฒƒ์ด ์•„๋‹˜.

    • ๊ทธ๋ƒฅ ๋ฌธ์ž ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ์€ ๊ฒƒ.

  • ์ด๋Ÿฐ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธฐ๋Š” ๊ฒƒ์„ ๋ง‰๊ธฐ ์œ„ํ•ด์„œ (ํšŒํ”ผ ํ•˜๊ธฐ ์œ„ํ•ด์„œ), ์ด๋Ÿฌํ•œ ์›น์—์„œ๋Š” ํŠน์ˆ˜ํ•œ ๋ชฉ์ ์œผ๋กœ ์‚ฌ์šฉ๋˜๋„๋ก ์•ฝ์†๋˜์—ˆ์ง€๋งŒ ๊ทธ๋ƒฅ ๋ฌธ์ž ๋กœ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋ณ€ํ™˜, ์น˜ํ™˜ํ•ด์ค˜์•ผํ•œ๋‹ค.

    • http://a.com?name=egoing&job=programmer%26blogger

    • & -> %26 ์œผ๋กœ ๋˜์—ˆ์Œ. (encodeURL)

    • ์ด๋Ÿฌํ•œ ๊ณผ์ •์„ ์ด์Šค์ผ€์ดํ•‘ ์ด๋ผ ๋ถ€๋ฅธ๋‹ค.

  • ์ •๋ฆฌํ•˜์ž๋ฉด,

    • ecsape ๋ž€, ํŠน์ • ๋ฌธ์ž(์•ฝ์†๋œ ๋ฌธ์ž) ๋ฅผ ์•ฝ์†๋œ ๋ชฉ์ ์ด ์•„๋‹Œ ๋‹ค๋ฅธ ๋ชฉ์ (๊ทธ๋ƒฅ ๋ฌธ์ž)๋กœ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ ์น˜ํ™˜ํ•ด์ฃผ๋Š” ๊ฒƒ์„ ์˜๋ฏธ.

    • unecsape ๋ž€, ecsape ๋œ ๋ฌธ์ž (์น˜ํ™˜๋œ ๋ฌธ์ž) ๋ฅผ ์›๋ž˜ ๋ฌธ์ž๋กœ ๋˜๋Œ๋ฆฌ๋Š” ์ž‘์—….

Javascript

  • encodeURI()

    • Not Escaped: A-Z a-z 0-9 ; , / ? : @ & = + $ - _ . ! ~ * ' ( ) #

    • ์œ„ ๋ฌธ์ž๋ฅผ ์ œ์™ธํ•œ ๋ชจ๋“  ๋ฌธ์ž๋ฅผ UTF-8๋กœ ์น˜ํ™˜,์ธ์ฝ”๋”ฉ ํ•œ๋‹ค (escape)

  • decodeURI()

  • ์ฐธ๊ณ  ๋ฌธ์„œ : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI

HTML , Java.. etc..

  • ํ•ด๋‹น ์–ธ์–ด์—์„œ ์„ค์ •ํ•œ ์•ฝ์†๋œ ๋ฌธ์ž๊ฐ€ ์žˆ๊ณ , ์‚ฌ์šฉ์ž๊ฐ€ ํ•ด๋‹น ์•ฝ์†๋œ ๋ฌธ์ž๋ฅผ ๊ทธ๋ƒฅ ๋ฌธ์ž ๋กœ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ์„ ๋•Œ๋Š” ์ด์Šค์ผ€์ดํ•‘์„ ํ•ด์•ผํ•จ.

  • ์ฆ‰ ํ™˜๊ฒฝ์— ๋”ฐ๋ผ์„œ, ์•ฝ์†๋œ ๋ฌธ์ž ๋‹ค๋ฅด๋‹ค๋Š” ๊ฑธ ์•Œ ์ˆ˜ ์žˆ์„๋“ฏ.

์ •๋ฆฌ

  • ๋‹จ์–ด์—์„œ ๋‚˜ํƒ€๋‚˜๋“ฏ์ด, ๋ญ”๊ฐ€๋ฅผ ํ”ผํ•˜๊ธฐ ์œ„ํ•ด์„œ์ž„.

  • ๊ทธ ๋ญ”๊ฐ€๊ฐ€ ๋ฌด์—‡์ด๋ƒ? ์•ฝ์†๋œ ๋ฌธ์ž์ž„.

  • ์•ฝ์†๋œ ๋ฌธ์ž์ง€๋งŒ, ๊ทธ ์šฉ๋„๋กœ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ์ง€ ์•Š์„ ๋•Œ escape ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๊ณ  ๋ณด๋ฉด ๋ ๋“ฏ.

  • ๊ทธ๋ฆฌ๊ณ  ํƒˆ์ถœ๋œ ๋ฌธ์ž๋“ค์„, ์ •์ƒ์œผ๋กœ ๋Œ๋ฆฌ๊ณ  ์‹ถ์„ ๋•Œ (์•ฝ์†๋œ ๋ฌธ์ž๋“ค๋กœ), unescape ํ•œ๋‹ค๊ณ  ๋ณด๋ฉด ๋  ๋“ฏํ•จ.

์ฐธ๊ณ 

  • https://opentutorials.org/course/50/199#:~:text=unescape%EB%8A%94%20escape%EB%A1%9C%20%EC%9D%B4%EC%8A%A4,%EB%8A%94%20decodeURI%2C%20decodeURIComponent%EA%B0%80%20%EC%9E%88%EB%8B%A4.

  • https://steady-snail.tistory.com/111

  • https://starrecode.tistory.com/11

Last updated