UTF-8, URL ์ธ์ฝ”๋”ฉ?

์™œ URL์„ ์ธ์ฝ”๋”ฉ ํ•˜๋Š”๊ฐ€?

์šฐ์„  URL encode์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด์ž. ์ž๋ฐ”์—์„œ๋Š” URLEncoder.encode() ๋ฉ”์„œ๋“œ๋ฅผ ํ†ตํ•ด์„œ ํ•ด๋‹น URL์„ ์ธ์ฝ”๋”ฉ ํ•  ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋Ÿผ ์™œ ํ•˜๋Š”๊ฐ€? URL์—๋Š” ASCII๋กœ๋งŒ ํ‘œํ˜„๋˜๊ธฐ ๋•Œ๋ฌธ์— ํ•œ๊ธ€, ํŠน์ˆ˜ ๋ฌธ์ž์™€ ๊ฐ™์€ ๊ฒƒ์€ ASCII๋กœ ํ‘œํ˜„ํ•  ์ˆ˜ ์—†๋‹ค ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— ์ธ์ฝ”๋”ฉ์„ ํ†ตํ•ด์„œ ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์ฝ์„ ์ˆ˜ ์žˆ๊ฒŒ ASCII ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜ ํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋œ๋‹ค.

Character From Windows-1252 From UTF-8
space %20 %20
! %21 %21
โ€ %22 %22
# %23 %23
$ %24 %24
% %25 %25
& %26 %26
โ€™ %27 %27
( %28 %28
) %29 %29
* %2A %2A
+ %2B %2B
, %2C %2C
- %2D %2D
. %2E %2E
/ %2F %2F

UTF-8(์œ ๋‹ˆ์ฝ”๋“œ) ์ด๋ž€?

์ „์„ธ๊ณ„์˜ ๋‹ค์–‘ํ•œ ๋ฌธ์ž๋“ค์„ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋งŒ๋“ค์–ด ์ง„๊ฒƒ์ด ์œ ๋‹ˆ์ฝ”๋“œ์ด๊ณ , ๊ทธ ์ค‘์—์„œ ๊ฐ€์žฅ ํž˜์„ ์–ป์€ ๊ฒƒ์ด UTF-8์ด๊ณ  ์„ธ๊ณ„์ ์ธ ํ‘œ์ค€์ด ๋˜์—ˆ๋‹ค.

์›๋ž˜๋Š” ์ด๊ฒƒ๋•Œ๋ฌธ์— ํฌ์ŠคํŒ… ํ•œ๊ฑด๋ฐ..

์ฝ”๋“œ์—์„œ ๋ณดํ†ต encํ• ๋•Œ ๋ณดํ†ต ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์•„๋ฌด๋ ‡์ง€ ์•Š๊ฒŒ ์ŠคํŠธ๋ง ๋ฌธ์ž์—ด "UTF-8"์„ ์‚ฌ์šฉํ•œ๋‹ค. ๋น„๊ต์  ์งง์•„์„œ ์˜คํƒ€๋Š” ์‰ฝ๊ฒŒ ํŒ๋ณ„ํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ์ฝ”๋“œ ์ƒ์— ๋ฌธ์ž์—ด์ด ๋“ค์–ด๊ฐ€ ์žˆ๋Š” ๊ฒƒ์ด ์ข‹์€์ง€ ๋‹ค์‹œ ํ•œ ๋ฒˆ ๊ณ ๋ฏผํ•ด๋ณด์ž! java.nio์—์„œ ์ด๋ฏธ ์ •์˜ํ•œ StandardCharsets.UTF_8.name() ์ด๋†ˆ์„ ์‚ฌ์šฉํ•˜์ž!

์ฐธ์กฐ

์—ฐ๊ด€ ํฌ์ŠคํŠธ