解决js导出csv中文乱码

function doCSV(json) {
            // 1) find the primary array to iterate over
            // 2) for each item in that array, recursively flatten it into a tabular object
            // 3) turn that tabular object into a CSV row using jquery-csv
            var inArray = arrayFrom(json);

            var outArray = [];
            for (var row in inArray)
                outArray[outArray.length] = parse_object(inArray[row]);

            $("span.rows.count").text("" + outArray.length);

            var csv = $.csv.fromObjects(outArray);
            // excerpt and render first few rows
            renderCSV(outArray.slice(0, excerptRows));
            showCSV(true);

            // if there's more we're not showing, add a link to show all
            if (outArray.length > excerptRows)
                $(".show-render-all").show();

            // show raw data if people really want it
            $(".csv textarea").val(csv);

            // download link to entire CSV as data
            // thanks to https://jsfiddle.net/terryyounghk/KPEGU/
            // and https://stackoverflow.com/questions/14964035/how-to-export-javascript-array-info-to-csv-on-client-side
            //var uri = "data:text/csv;charset=utf-8," + encodeURIComponent(csv);
            var uri = "data:text/csv;charset=utf-8,uFEFF" + encodeURI(csv);
            $(".csv a.download").attr("href", uri);
        }

  解决js导出csv中文乱码

原文地址:https://www.cnblogs.com/wuhailong/p/7605288.html