일반 텍스트로 응답하는 웹 서비스를 쿼리하려고합니다. 텍스트에는 종종 독일어 umlauts이 있습니다. 수신 된 스트림에서 움라우트가 깨졌습니다. 어떤 아이디어가 내가 뭘 잘못하고 있니?요청을받을 때 Umlauts가 깨졌습니다.
var request = require('request');
var uri = <anUriWithUserId>;
request(uri, {encoding: 'utf8','content-type': 'text/plain; charset=UTF-8'},
function (error, response, body)
{
console.log("encoding: " + response.headers['content-encoding']);
console.log("type: " + response.headers['content-type']);
console.log(body);
});
그리고 응답 : 귀하의 요청 전화에 encoding
옵션을 설정하면
encoding: undefined
type: text/plain
error=0
---
asin=
name=Eistee
detailname=Pfanner Der Gr�ne Tee, Zitrone - Kaktusfeige, 2,0 l
vendor=Hermann Pfanner Getr�nke GmbH, Lauterach, �sterreich
maincat=Getr�nke, Alkohol
'console.log ('üäö ');가 잘 작동하기 때문에 터미널이 아닙니다. – Torsten
가능한 답변 : (http://stackoverflow.com/questions/16267274/how-to-get-utf-8- in-node-js) – PeterVC
어쩌면 그냥 오타 일 수도 있지만'content-type'은 따옴표로 묶이지 않아야합니다 ... – Dunken