0

I tried to fetch meta data from document and get the data in the false encoding:

var fetchPageMetaData = function () {
    var result = [];
    var metaDataList = document ? document.querySelectorAll('head meta') : [];
    for (var i = 0; i < metaDataList.length; i++) {
        var meta = metaDataList[i];
        var object = {};
        if (meta && meta.attributes) {
            for (var j = 0; j < meta.attributes.length; j++) {
                var attr = meta.attributes[j].nodeName;
                object[attr] = meta.attributes[j].nodeValue;
            }
            result.push(object);
        }
    }
    return result;
}

Testing the code with Mocha and getting this result for thie page: page with meta data Result:

[{
    "content": "text/html; charset=iso-8859-1",
    "http-equiv": "Content-Type"
},
{
    "content": "www.cm4all.com",
    "name": "GENERATOR"
},
{
    "content": "Tennis, Fussball, Hobbies",
    "name": "keywords"
},
{
    "content": "Meine tolle Seite �ber Fussball und Tennis",
    "name": "description"
},
{
    "content": "Meine tolle Seite �ber Fussball und Tennis",
    "name": "abstract"
}]

Expecting result with ü instead of .

halfer
  • 19,824
  • 17
  • 99
  • 186
Thami Bouchnafa
  • 1,987
  • 1
  • 15
  • 21
  • possible duplicate of [How to convert character encoding from CP932 to UTF-8 in nodejs javascript, using the nodejs-iconv module (or other solution)](http://stackoverflow.com/questions/6411570/how-to-convert-character-encoding-from-cp932-to-utf-8-in-nodejs-javascript-usin) – stdob-- Jul 09 '15 at 13:12
  • I don't think so, i assume it's because the test framework [mocha](http://mochajs.org/), because the result is only not encoded in the test, otherwise all is right outside the test – Thami Bouchnafa Jul 10 '15 at 06:24

0 Answers0