메뉴 건너뛰기

2014.04.29 19:58

문자셋 설정, charset

조회 수 7480 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

아파치 웹서버 설정파일에 문자셋을 지정할 수 있다.

하지만 HTML 문서등을 작성할때 문자셋을 지정하면 이 값이 다른 값보다 우선시된다.

php 설정에서도 기본 문자셋을 지정할 수 있다.


서버에서 문자셋 설정하기

 

Apache 웹서버 UTF-8 설정

httpd.conf 에 추가하면 되는데 리눅스 배포판 별로 다르다.
AddDefaultCharset UTF-8 


PHP UTF-8 설정

php.ini 에서 다음과 같이 수정 한다.

[PHP]

default_charset = "UTF-8"

output_handler = mb_output_handler


[mbstring]

mbstring.language = UTF-8

mbstring.internal_encoding = UTF-8

mbstring.http_input = auto

mbstring.http_output = UTF-8                    

mbstring.encoding_translation = On

mbstring.detect_order = auto

mbstring.substitute_character = none;


[PHP_MBSTRING]

extension=php_mbstring.dll


MySQL UTF-8 설정

my.cnf 파일을 수정한다.

[client]

default-character-set = utf8


[mysqld]

character-set-client-handshake=FALSE

init_connect="SET collation_connection = utf8_general_ci"

init_connect="SET NAMES utf8"

character-set-server = utf8 

collation-server = utf8_general_ci


[mysqldump]

default-character-set = utf8


[mysql]

default-character-set = utf8

 

코딩시 직접 문자셋 설정하기

 

HTML 설정

# HTML 파일을 UTF-8로 만들어 저장한다.

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


XML 설정

# XML 파일을 UTF-8로 만들어 저장한다.

<?xml version="1.0" encoding="UTF-8" ?>

CSS 설정

# css 파일의 맨 위에 지정한다.

@charset "utf-8";


PHP 설정

# 서버에 지정된 문자셋을 무시한다.

<?php  header("Content-Type: text/html; charset=UTF-8"); ?>


Javascript 설정

# HTML 문서의 문자셋과 상관없이 인식된다.

<script type="text/javascript" src="path/file.js" charset="utf-8"></script>


상황

서버 설정 부분에 


1. httpd.conf 에서 기본언어설정안함 

# AddDefaultCharset UTF-8 


2. php.ini 에서 기본언어설정안함 

; default_charset = "iso-8859-1" 

; default_charset = "utf-8" 


3. my.cnf 에서 캐릭터셋 수정 


[client] 

#password = your_password 

default-character-set=utf8 


[mysqld] 

init_connect=SET collation_connection = utf8_general_ci 

init_connect=SET NAMES utf8 

default-character-set=utf8 

character-set-server=utf8 

collation-server=utf8_general_ci 


[mysql] 

default-character-set=utf8 

================================================== 


위 상태에서 아래 두가지 버전모두 운영이 가능합니다. 


그누보드4 UTF-8 = 한글 입출력 아무이상없음, 

그누보드4 EUC-KR = 한글 정상출력(phpmyadmin 에서만 한글이 깨짐), 


================================================== 


httpd.conf 에서 

AddDefaultCharset UTF-8 로 지정할경우는 


EUC-KR 버전은 한글 깨지는데 브라우저에서 인코딩을 지정하면 정상출력, 

새로고침하면 다시 한글깨짐. 이렇게 되더군요... 


참고하시라고 올려드립니다..

출처 :https://lael.be/116


List of Articles
번호 제목 날짜 조회 수
157 Linux 시스템 백업과 복원 2014.03.26 7862
156 LINUX 싱글부팅 2014.03.26 7419
155 linux 커널 파라메터 수정 2014.02.27 7094
154 mail 명령어 사용법 2014.03.26 7110
153 mariadb | my.cnf 설정. MariaDB(5.5.37) utf8 설정 2015.07.16 7711
152 mod_expires 모듈 추가 및 이미지 캐싱 설정방법 2014.02.27 7862
151 mod_rewrite 예제 2016.12.22 7145
150 my.cnf 케릭터 셋 설정 (uft8) 2015.07.16 7290
149 mysql DB 지정 백업 스크립트 2016.03.18 8004
148 MySQL Linux Port 방화벽 설정(3306) file 2017.03.11 9468
147 mysql root 비밀번호 설정 2015.07.16 7858
146 MySQL 계정생성하기 2015.07.16 7511
145 Mysql 설치시 LinuxThreads 에러 메세지 2014.02.27 7501
144 ncftp 설치및 스크립트 백업 방법 file 2014.02.27 7928
143 netstat [option] 2014.04.12 7238
142 netstat 명령어 2021.03.26 210
141 netstat 사용법 2016.12.22 8768
140 Nikto - 웹 취약점 스캐너 도구 file 2016.04.22 9232
139 OpenSSH chroot 설정 file 2014.02.27 8742
138 php http include 2016.03.18 7685
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 12 Next
/ 12

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved