Setting the HTTP charset parameter
Content-Type: text/html; charset=utf-8
Server setup
AddCharset(Apache 1.3.10 and later) or AddType
AddDefaultCharset(Apache 1.3.12 and later)
IIS 5 and 6. In Internet Services Manager, right-click "Default Web Site" (or the site you want to configure) and go to "Properties" => "HTTP Headers" => "File Types..." => "New Type...". Put in the extension you want to map, separately for each extension; IIS users will probably want to map .htm, .html,... Then, for Content type, add "text/html;charset=iso-8859-1" (without the quotes; substitute your desired charset for iso-8859-1; do not leave any spaces anywhere because IIS ignores all text after spaces). For IIS 4, you may have to use "HTTP Headers" => "Creating a Custom HTTP Header" if the above does not work.
Scripting the header
Perl. Output the correct header before any part of the actual page. After the last header, use a double linebreak, e.g.:
print "Content-Type: text/html; charset=utf-8\n\n";
Python. Use the same solution as for Perl (except that you don't need a semicolon at the end).
PHP. Use the header() function before generating any content, e.g.:
header('Content-type: text/html; charset=utf-8');
Java Servlets. Use the setContentType method on the ServletResponse before obtaining any object (Stream or Writer) used for output, e.g.:
resource.setContentType ("text/html;charset=utf-8");
If you use a Writer, the Servlet automatically takes care of the conversion from Java Strings to the encoding selected.
JSP. Use the page
directive e.g.:
<%@ page contentType="text/html; charset=UTF-8" %>
Output from out.println()
or the expression elements (<%= object
%>
) is automatically converted to the encoding selected. Also, the page itself is interpreted as being in this encoding.
ASP and ASP.Net. content type and charset are set independently, and are methods on the response object. To set the charset, use e.g.:
<%Response.charset="utf-8"%>
In ASP.Net, setting Response.ContentEncoding will take care both of the charset parameter in the HTTP Content-Type as well as of the actual encoding of the document sent out (which of course have to be the same). The default can be set in the globalization
element in Web.config
(or Machine.config
, which is originally set to UTF-8).
W3C 출처: http://www.w3.org/International/O-HTTP-charset
'WEB언어' 카테고리의 다른 글
검색엔진이 긁어가는 것 막기 ( 검색엔진 배제 robots.txt 이용 ) (0) | 2010.08.24 |
---|---|
모바일 User-Agent로 변환하는 Firefox PlugIn (0) | 2010.06.11 |
위지윅(WYSIWYG)편집기 ( htmlarea.com ) (0) | 2010.01.08 |
인터넷 브라우저 사용추이 (2009-10-05) (0) | 2009.10.06 |
[Flash&Flex] flex video player 구글코드(GNU) (0) | 2009.06.02 |
[Flash&Flex] JW FLV Media Player (flv플레이어) (0) | 2009.04.14 |
[Flash&Flex] fcsh.exe, Flex 3 Compiler Shell (0) | 2009.01.08 |
[PHP]euc-kr 문자셋 서버에서 utf-8 urlencode하기 (1) | 2008.11.03 |
(로그인하지 않으셔도 가능)