我有一个包含键和一些值的hashmap,例如:
final Map<String, String> map = new HashMap<>();
{
map.put("01", "Example – Description");
map.put("02", "Example – Description")
}
hashmap中的值,description包含一个连字符,当输出到CSV文件时,它不能正确显示,而是显示&#39; x96&#39;。我知道这里有一些编码需要完成 - UTF-8?
我的问题是,你如何为哈希映射做到这一点?
我在这样的方法中访问这些值:
add[0] = updateSomething[0] + " " + map.get(e.getKey());
答案 0 :(得分:0)
要强制使用UTF-8,请使用以下命令指定JVM文件编码:
"type": "virtualbox-iso",
"guest_os_type": "Debian_64",
"guest_additions_mode": "disable",
"headless": "{{user `HEADLESS`}}",
"disk_size": "{{user `DISK_SIZE`}}",
"http_directory": "http",
"iso_url": "{{user `ISO_URL`}}",
"iso_checksum": "{{user `ISO_CHECKSUM`}}",
"iso_checksum_type": "{{user `ISO_CHECKSUM_TYPE`}}",
"ssh_port": 22,
"ssh_private_key_file": "C:/users/xxxxx/test_key.ppk",
"ssh_username": "root",
"ssh_wait_timeout": "10000s",
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/shutdown -hP now",
"vm_name": "{{user `VM_NAME`}}",
请参阅Setting the default Java character encoding?
完成上述操作后,请确保您也使用UTF-8编码打开CSV。