Bali Bali wrote: > > Below code: > -- > s1 = "good" > > File.new("test.xml", "w+") << s1 > -- > > It always give a file ANSI encoded. How can I get it UTF-8 encoded? > > If your ruby version < "1.9" $KCODE = "UTF8" else #!/usr/bin/env ruby # encoding: utf-8 <--- this line end (NOTES : above code is not legal ruby code) -- View this message in context: http://www.nabble.com/How-to-save-string-to-a-file-as-UTF-8-tp24731209p24731698.html Sent from the ruby-talk mailing list archive at Nabble.com.