1

nodejs を使用してブラウザに漢字の応答を表示できませんか?

jsdom.env({ html: 'http://www.baidu.com',
    scripts: ['http://code.jquery.com/jquery-1.6.min.js']
}, function (err, window) {
    //Use jQuery just as in a regular HTML page
    var $ = window.jQuery;

    res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
    res.end($('title').text());
});

誤った結果 : �ٶ�क�£��������

正しい結果は : 百度一下,你就知道

4

1 に答える 1

1

因として百度的网页编码是GBK的</p>

Baidu.com の文字セットは GBK であるため

于 2012-03-14T09:10:40.947 に答える