d3.js使用ISO-8859-1编码加载csv文件 [英] d3.js loading csv files with ISO-8859-1 encoding

查看:190
本文介绍了d3.js使用ISO-8859-1编码加载csv文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解析用d3.js编码的ISO-8859-1编码的csv文件。上升的字符中断。

I'm trying to parse csv files that are ISO-8859-1 encoded with d3.js. Ascended characters break.

我知道将文件转换为UTF-8可以解决问题。在这种情况下,这不是一个选项。

I know converting the file to UTF-8 would solve the problem. This is not an option in this case.

有没有办法以某种方式正确读取这些文件?如果可能的话,用javascript对它们进行重新编码就可以了。

Is there a way of reading these files correctly somehow? Re-coding them with javascript would work if that is possible.

我只能通过javascript访问数据,因为我的学院正在创建文件但它们没有知道像编码这样的事情。这些发布到我只能阅读的地方。

I only have access to the data through the javascript since my colleges are creating the files and they don't know about things like encoding. These are posted to a place I can only read from.

推荐答案

您可以明确指定mime类型和内容编码,例如

You can specify the mime type and content encoding explicitly, e.g.

d3.dsv(fieldSeparator, "text/plain; charset=ISO-8859-1");

这篇关于d3.js使用ISO-8859-1编码加载csv文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆