[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: Saving an UTF-8 file
From:       Paul Lutus <nospam () nosite ! zzz>
Date:       2006-11-12 11:30:05
Message-ID: 12le17ksi1v3jaa () corp ! supernews ! com
[Download RAW message or body]

Miquel Oliete wrote:

> Hi All
> 
> I have a problem (newbie problem).
> 
> I don't know how to write a file using utf-8 encoding. Can you help
> me.

utf-8 is simply 8-bit bytes. Save your data like this:

# "data" contain the text data

File.open(file_path,"w") { |f| f.write data }

utf-8 refers to a convention regarding the content of the bytes and how they
are interpreted when read. It isn't something you can specify in a
plain-text file. It can be inferred from the format of the bytes, but that
is an open interpretation.

http://dict.die.net/utf-8/

-- 
Paul Lutus
http://www.arachnoid.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic