jeudi 6 mars 2014

How change charset of file topic




Hi,

I try to create file with utf-8 charset.


If I do

File.open("test.xml", 'w:utf-8') { |f| f.write('<?xml version="1.0" encoding="UTF-8"?>') }

file -I test.xml -> test.xml: application/xml; charset=us-ascii

and I do

File.open("test.xml", 'w:utf-8') { |f| f.write('<?xml version="1.0" encoding="UTF-8" é?>') }

I add an utf-8 char (é)

file -I test.xml -> test.xml: application/xml; charset=utf-8

Ruby seem to be adaptative. But I would have alwayse charset utf-8. Can we do this ?

I use ruby 2.1.1





Aucun commentaire:

Enregistrer un commentaire