๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์„ ํ˜ธํ•˜๋Š”๊ฐœ๋ฐœ

classic asp ์—์„œ ํ•œ๊ธ€๊นจ์ง ์ฒ˜๋ฆฌ!! IE์™€ ๊ทธ์™ธ ๋ธŒ๋ผ์šฐ์ € ๋ณ„๋„ ์ฒ˜๋ฆฌ, ์ ‘์† ๋ธŒ๋ผ์šฐ์ € ์ฒดํฌ

๊ตฌ๊ธ€๋ง์„ ์•„๋ฌด๋ฆฌ ํ•ด๋„, ๊ทธ์ € ํ•œํŽ˜์ด์ง€ ์ „์ฒด๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š” ๋‚ด์šฉ๋ฐ–์— ์—†์–ด์„œ.....ํ—ค๋งค๋‹ค๊ฐ€....

๊ทธ๋Ÿฌ๋‹ค ๋ฌธ๋“ ์žฌ์„ ์–ธ์„ ํ†ตํ•ด ๊ฐ€๋Šฅํ•  ๊ฒƒ ๊ฐ™์•„์„œ ํ–ˆ๋”๋‹ˆ!!! ํ•ด๊ฒฐ~ ํ–ˆ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์ง€๋งŒ

ieํ•˜๊ณ , ํฌ๋กฌํ•˜๊ณ  ๋‹ค๋ฅด๊ฒŒ ์ ์šฉ์„ ํ•ด์•ผ ํ•œ๋‹ค๋Š”๊ฒƒ์„ ๋ฐœ๊ฒฌํ•˜๊ณ  ๋‹ค์‹œ ์ˆ˜์ •ํ•˜์—ฌ ์™„์„ฑ!!โ€‹

์ž‘์—…ํ•œ ๋‚ด์šฉ์„ ๊ฐ„๋‹จํ•˜๊ฒŒ ์ ์–ด๋ณด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

1. escape, unescape ์„œ๋ฒ„ ํ•จ์ˆ˜๋กœ ์„ ์–ธ

2. Request.ServerVariables("HTTP_USER_AGENT") ์—์„œ msie ์™€ trident ์ธ๊ฒฝ์šฐ๋ฅผ ie ์ธ ๊ฒƒ์œผ๋กœ ์ฒดํฌ

(msie ์ฐพ๋Š”๊ฑด ์˜ˆ์ „ ๋ฐฉ์‹์ธ๊ฒƒ ๊ฐ™๊ณ , ์‹ค์ œ Request.ServerVariables("HTTP_USER_AGENT") ๋ฟŒ๋ ค๋ณด๋ฉด, trident ๊ฐ€ ie์—๋งŒ ์žˆ๋Š”๊ฒƒ์„ ํ™•์ธํ•จ)

3. ie์ธ ๊ฒฝ์šฐ์— euc-kr ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ค์ •ํ•ด์„œ ํŒŒ๋ผ๋ฏธํ„ฐ ๊ฐ’์„ ๋ฐ›์•„์„œ, escape ์ฒ˜๋ฆฌ

4. utf-8 ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์„ค์ •ํ•˜๊ณ  escape ์ฒ˜๋ฆฌํ•œ๊ฐ’์„ unescape ์ฒ˜๋ฆฌํ•ด์„œ ๋‹ค์‹œ ๋ณ€์ˆ˜์— ํ• ๋‹น!

5. ํฌ๋กฌ(chrome)์ธ ๊ฒฝ์šฐ์—๋Š” utf-8 ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์„ค์ • ํ•œ ํ›„์— ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๋ณ€์ˆ˜์— ํ• ๋‹น!โ€‹

์ „์ฒด ์†Œ์Šค๋Š” ์•„๋ž˜์— ์žˆ์Šต๋‹ˆ๋‹ค!!

<%'s 1. ํ•œ๊ธ€ ํ‚ค์›Œ๋“œ ๊นจ์ง ํ˜„์ƒ ํ•ด๊ฒฐ %>
<script language="javascript" runat="server">
function escapeUTF8(str) {
  return escape(str);
}

function unescapeUTF8(str) { 
  return unescape(str);
}
</script>
<%
Response.CharSet = "euc-kr"
Session.CodePage = "949"
Response.CodePage = "949"
Response.ContentType = "text/html;charset=euc-kr"
DIm CHECK_IE : CHECK_IE = "F"
Dim EUCKR_KEYWORD
Dim USER_AGENT : USER_AGENT = LCase(Request.ServerVariables("HTTP_USER_AGENT"))

IF InStr(USER_AGENT, "msie") > 0 Or InStr(USER_AGENT, "trident") > 0 Then
  CHECK_IE = "T"
  EUCKR_KEYWORD = escapeUTF8(Request("kw")) 'utf-8 ํŽ˜์ด์ง€ ์ „ํ™˜ ๋˜๊ธฐ ์ „์— IE์—์„œ๋งŒ ์ธ์ฝ”๋”ฉ ์ฒ˜๋ฆฌ ํ•˜์—ฌ, ํ•œ๊ธ€ ๊นจ์ง ๋ฐฉ์ง€
End If
'e 1. ํ•œ๊ธ€ ํ‚ค์›Œ๋“œ ๊นจ์ง ํ˜„์ƒ ํ•ด๊ฒฐ
%>
<%
Response.Buffer   = TRUE
Response.Expires  = -1
Response.CharSet = "utf-8"
Session.CodePage = "65001"
Response.CodePage = "65001"
Response.ContentType = "text/html;charset=utf-8"
Response.AddHeader "Pragma","no-cache"
Response.AddHeader "Expires","0"

's 2. ํ•œ๊ธ€ ํ‚ค์›Œ๋“œ ๊นจ์ง ํ˜„์ƒ ํ•ด๊ฒฐ
IF CHECK_IE = "T" Then
  EUCKR_KEYWORD = unescapeUTF8(EUCKR_KEYWORD) '๋ณ€ํ™˜๋œ ๊ฐ’์„ ๋””์ฝ”๋”ฉ
Else 
  EUCKR_KEYWORD = Request("kw") 'IE์ด์™ธ์—์„œ๋Š” ๋„˜์–ด์˜จ๋Œ€๋กœ ๋ฐ›์Œ, ํ•œ๊ธ€ ๊นจ์ง ๋ฐฉ์ง€
End If
'e 2. ํ•œ๊ธ€ ํ‚ค์›Œ๋“œ ๊นจ์ง ํ˜„์ƒ ํ•ด๊ฒฐ
%>

์ด๊ฑฐ ์™ธ์—, ์†Œ์Šค์ƒ์—์„œ escape๋กœ ๋ณ€ํ™˜ํ•˜๋Š”๋ถ€๋ถ„๋“ค์„ ie, chrome ํฌ๋กœ์Šค ์ฒดํฌํ•˜๋ฉด์„œ ํ™•์ธํ•ด์„œ ์ฒ˜๋ฆฌ์™„๋ฃŒ.

์ง€๋‚œ์ฃผ์— ์š”์ฒญ์ด ๋“ค์–ด์™€์„œ, ์ด๊ฑธ ์–ด๋–ป๊ฒŒ ์ฒ˜๋ฆฌํ•ด์•ผํ•˜๋‚˜ ๊ณ ๋ฏผํ–ˆ์—ˆ๋Š”๋ฐ

ํ•ด๊ฒฐํ•ด์„œ ๊ธฐ๋ถ„์ด ๋งค์šฐ ์ข‹๋„ค์š”~