프로그래밍/Node.js

Node.js - response.end 한글 깨짐 현상 해결법

가카리 2015. 1. 5. 10:28
반응형

//모듈을 추출합니다.

var http = require('http');

 

//서버를 생성 실행합니다.

http.createServer(function(request, response){

 

      response.writeHead(200, {'Content-Type': 'text/html;charset=UTF-8'});

      //response.write(body, "utf8");

      response.end('<h1>Test - File = 2 출력 </h1> ');

     

     

}).listen(52273, function(){

      console.log('Server Running at http://127.0.0.1:52273');

});

 

 

한글깨짐을 해결하기위해서 UTF-8을 사용한다는 것을 나타내줘야한다.

 

즉, 위와같이 빨간부분을 추가하면된다.

 

반응형