ACTIVE SERVER PAGE > UTF-8 ÇÁ·Î±×·¡¹Ö ¹æ¹ý (Çѱ۱úÁü ¹æÁö¸¦ À§ÇÑ ¹æ¹ýµé)
µî·ÏÀÏ : 2017-07-04 18:18
Á¶È¸¼ö : 55,284
1. ¸ðµç ASP ÄÚµå ÆäÀÌÁö ùÁÙ¿¡ ´ÙÀ½°ú °°Àº Äڵ带 Ãß°¡ÇÕ´Ï´Ù
@CODEPAGE="65001" language="vbscript"
session.CodePage = "65001"
Response.CharSet = "utf-8"
Response.buffer=true
Response.Expires = 0
2. Meta Åױ׸¦ ´ÙÀ½°ú °°ÀÌ Ãß°¡ ÇÕ´Ï´Ù.
¾Æ¸®·¯´ÏÇÏ°Ôµµ XHTML °ú HTML5 ¿¡¼ÀÇ ÀÎÄÚµù ¼³Á¤Àº ´Ù¸£´Ù.
XHTMLÀÇ °æ¿ì¿¡´Â ¾Æ·¡ Äڵ带 <head> ÅÂ±× ¾È¿¡ »ðÀÔÇÑ´Ù.
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
HTML5ÀÇ °æ¿ì ¾Æ·¡ Äڵ带 <head> ÅÂ±× ¾È¿¡ »ðÀÔÇÑ´Ù.
<meta charset="utf-8">
±×¸®°í ÁÖÀÇÇØ¾ß ÇÒ ºÎºÐÀÌ ¸ÞŸÅ×±× ³»ÀÇ Ä³¸¯ÅͼÂÀÌ´Ù.
¸¸¾à ŸÀÌƲÀÌ ÇѱÛÀ̶ó¸é ºê¶ó¿ìÀú¿¡ µû¶ó ij¸¯ÅͼÂÀ» ¼±¾ðÇϱâ ÀüºÎÅÍ ÇÑ±Û ÀÎÄÚµùÀÌ °áÁ¤´Â °æ¿ì°¡ ÀÖ´Ù
(ÀÌÈÄ Ä³¸¯ÅÍ ¼ÂÀ» Á¤ÀÇÇÑ´Ù°í Çصµ ¼Ò¿ë¾øÀ½)
¸¸¾à ŸÀÌƲÀÌ ÇѱÛÀÏ °æ¿ì´Â ¼ø¼¸¦ ij¸¯Åͼ ¼±¾ð ÀÌÈÄ·Î ÇØÁà¾ß ÇÑ´Ù.
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>°¡³ª´Ù</title>
-- ÁÖÀÇ : UTF-8 °ú utf-8 Àº ¼·Î ´Ù¸¥ ŸÀÔÀÇ ÀÎÄÚµùÀ» Á¦°øÇÑ´Ù. ÇÑ°¡Áö·Î ÅëÀÏÇؼ »ç¿ëÇÏÀÚ.
3. Response.ChaRset = "utf-8"
ASPÀÇ response.charsetÀ» ÀÌ¿ëÇؼ ¹®ÀÚ ÄÚµå ¼¼Æ®¸íÀ» ÁöÁ¤ÇÏ´Â ºÎºÐ ÀÔ´Ï´Ù.
¼³Á¤½Ã <html> ÅÂ±× º¸´Ù ¾Õ¿¡ ¼±¾ð µÇ¾î¾ß HTML ÀÌ Ãâ·ÂµÇ¸é¼ ÇØ´ç ¼Ó¼ºÀ» ÀνÄÇÏ°Ô µË´Ï´Ù.
4. ¿¡µðÆ®Ç÷¯½º³ª ¿ïÆ®¶ó ¿¡µðÅÍ¿¡¼ ¼öÁ¤ÈÄ ÀúÀåÇÒ ¶§ ¹Ýµå½Ã Encoding ¹æ½ÄÀ» UTF-8 ·Î ÀúÀåÇÕ´Ï´Ù
5.DB Insert/Update ½Ã ¼ýÀÚ Å¸ÀÔÀ» Á¦¿ÜÇÑ ¸ðµç ´ë»ó¿¡ NÀ» Ãß°¡ ÇÕ´Ï´Ù
Insert Å×À̺íÀ̸§ (Ä®·³a, Ä®·³b) value (N'ÀÔ·Âa', N'ÀÔ·Âb')
update Å×À̺íÀ̸¦ set Ä®·³a = N'ÀÔ·Âa' where °íÀ¯Ä®·³ = '¹øÈ£'
6.DB like °Ë»ö½Ã N Ãß°¡
7. ÆÄÀÏ Ã·ºÎ DEXT Upload»ç¿ë(¿µ¹®À¸·Î ¼³Ä¡)
SET uploadform = Server.CreateObject("DEXT.FileUpload")
uploadform.DefaultPath = Server.MapPath(ESP_BBS_DATA)
uploadform.CodePage = 65001
wFileSize = 0
rAttachment = uploadform("txtAttachFile")
If Len(rAttachment) > 0 Then
wFileName = uploadform("txtAttachFile").FileName
wFileSize = uploadform("txtAttachFile").FileLen
response.write uploadform.DefaultPath
rAttachment = uploadform.SaveAs(uploadform.DefaultPath & "" & wFileName , False)
rAttachment = UploadForm.LastSavedFileName
End If
9. CDO Mail¹ß¼Û
Dim iMsg
Dim iConf
Dim Flds
Dim strHTML
Const cdoSendUsingPort = 2 '1:·ÎÄÃ, 2:¿ÜºÎ smtp
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
Flds.item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'Æ÷Æ®¹øÈ£
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "" 'ID
Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "" '¾ÏÈ£
Flds.Update
Set iMsg.Configuration = iConf
iMsg.To = "xxxx@xxx.ccx" 'ToDo: Enter a valid email address.
iMsg.From = "xxxx@xxx.ccx" 'ToDo: Enter a valid email address.
iMsg.Subject = "This is a test CDOSYS message (Sent via Port 25)"
'iMsg..TextBody = strHTMLMsg '// ÅؽºÆ®
iMsg.HTMLBody = strHTML '// HTML Á¦¸ñ ±úÁü ¹ß»ý..
iMsg.BodyPart.Charset="UTF-8" '/// ÇѱÛÀ» À§Çؼ± ²À ³Ö¾î ÁÖ¾î¾ß ÇÕ´Ï´Ù.
iMsg.HTMLBodyPart.Charset="UTF-8" '/// ÇѱÛÀ» À§Çؼ± ²À ³Ö¾î ÁÖ¾î¾ß ÇÕ´Ï´Ù.
iMsg.Send
End With
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
10. ÇÑ±Û ¸µÅ©°¡ Æ÷ÇԵǾî ÀÖ´Â °æ¿ì Target ÆäÀÌÁö¿¡¼ ÇѱÛÀÌ ±úÁö´Â Çö»ó ÇØ°á ¹æ¹ý
Server °´Ã¼ÀÇ URLPathEncode ÇÔ¼ö¸¦ »ç¿ëÇؼ ¹ÞÀ¸¸é µÈ´Ù.
Server.UrlEncode() ¸¦ »ç¿ëÇصµ µË´Ï´Ù.
fname = request("fname")
<a href="a.asp?fname=<%=Server.URLPathEncode(fname)%>"> ¸µÅ©°¡±â </a>
11. ¾÷·Îµå ÄÄÆ÷³ÍÆ® UTF-8 Áö¿ø¿©ºÎ È®ÀÎ
SiteGalaxy(»çÀÌÆ® °¶·°½Ã) ¹× ABC ¾÷·Îµå : utf-8À» Áö¿øÇÏÁö ¾ÊÀ½
ABC ¾÷·Îµå : 4.1 ºÎÅÍ Áö¿ø
µ¦½ºÆ®¾÷·Îµå´Â 3.x ÀÌÈÄ Áö¿ø
set UploadForm = Server.CreateObject("ABCUpload4.XForm")
UploadForm.CodePage = 65001
UploadForm.Overwrite = True 'µ¤¾î¾²±â Çã¿ë
UploadForm.AbsolutePath = True
UploadForm.MaxUploadSize = 1024*1024*20 'ÆÄÀÏ¿ë·® (10M)
If UploadForm("board_fname1") <> "" Then
FileCnt = UploadForm("board_fname1").count-1
Else
FileCnt = 0
End If
Dim UpFileName()
Redim UpFileName(FileCnt)
'ÆÄÀÏ ¾÷·Îµå ó¸®
For i = 0 To FileCnt
Set theField = UploadForm(Trim("board_fname1"))(i+1)
Next
12. ÆÄÀÏ´Ù¿î·Îµå - ÇѱÛÆÄÀÏ¸í ±úÁö´Â Çö»ó
¾Æ·¡¼Ò½ºÀÇ ÇÙ½ÉÀº Server.URLPathEncode °´Ã¼¸¦ ÀÌ¿ëÇÏ´Â °Ì´Ï´Ù.
<a href="a.asp?fname=<%=Server.URLPathEncode(fname)%>"> ´Ù¿î·Îµå </a>
<%@ CODEPAGE=65001%>
<%session.CodePage = "65001" %>
<%response.charset = "utf-8"%>
<%
Response.buffer=true
Response.Expires = 0
'Response.ContentType = "application/octet-stream"
'Response.ContentType = "application/unknown"
Response.ContentType="application/x-gzip"
fname = request("fname")
fpath = request("fpath")
Response.AddHeader "Content-Disposition","attachment; filename=" & Server.URLPathEncode(fname)
UP_FILE_DIR = "/file_data/"&FPATH&FNAME
UP_FILE_DIR = Server.MapPath(UP_FILE_DIR)
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.LoadFromFile UP_FILE_DIR
strFile = objStream.Read
Response.BinaryWrite strFile
Set objStream = Nothing
response.End
%>
13. Javascript ¸¦ ÀÌ¿ëÇÏ¿© ÇѱÛÀ» ¸µÅ© ¿¬°áÇÒ°æ¿ì´Â escape() ÇÔ¼ö¸¦ ÀÌ¿ëÇÏ¿© ¸µÅ©¸¦ °É¾îÁÖ¾î¾ß ÇÕ´Ï´Ù.
document.location.href = "movepage.aspx?name=" + escape("¹èö¼ö");