Mac OS Roman import?

Поиск
Список
Период
Сортировка
Искать

Mac OS Roman import?

От:
Christophe Pettus <xof@thebuild.com>
Дата:
Greetings,

I find myself needing to regularly import data encoded as Mac OS Roman  
(yes, it is coming from an Macintosh OS 9 system) into a UTF-8  
PostgreSQL database.  Any advice on how to do so, since Mac OS Roman  
is (reasonably enough) not one of PG's standard character encodings?

Thanks!
--
-- Christophe Pettus
    xof@thebuild.com

Re: Mac OS Roman import?

От:
Sam Mason <sam@samason.me.uk>
Дата:
On Mon, Oct 19, 2009 at 02:54:38PM -0700, Christophe Pettus wrote:
> I find myself needing to regularly import data encoded as Mac OS Roman  
> (yes, it is coming from an Macintosh OS 9 system) into a UTF-8  
> PostgreSQL database.

How tightly integrated into PG do you want it?  You can define custom
character conversions if you want (although I've never tried this).
Python appears to know how to convert to/from "MacRoman"[1] by default,
so pl/python should make this reasonably easy.

Otherwise, iconv is a useful tool.  The project's homepage suggests
that it knows how to do the conversions, but I can't figure out the
command line needed.

-- 
  Sam  http://samason.me.uk/

 [1] http://docs.python.org/library/codecs.html
 [2] http://www.gnu.org/software/libiconv/

Re: Mac OS Roman import?

От:
Scott Ribe <scott_ribe@killerbytes.com>
Дата:
> I find myself needing to regularly import data encoded as Mac OS Roman
> (yes, it is coming from an Macintosh OS 9 system) into a UTF-8
> PostgreSQL database.  Any advice on how to do so, since Mac OS Roman
> is (reasonably enough) not one of PG's standard character encodings?

Use iconv; it's a command shipped with OS X, man iconv for more info.

-- 
Scott Ribe
scott_ribe@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


Re: Mac OS Roman import?

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Christophe Pettus  writes:
> I find myself needing to regularly import data encoded as Mac OS Roman  
> (yes, it is coming from an Macintosh OS 9 system) into a UTF-8  
> PostgreSQL database.  Any advice on how to do so, since Mac OS Roman  
> is (reasonably enough) not one of PG's standard character encodings?

Maybe iconv knows about it?  Or it might be that it's close enough to
ISO 8859-something that you could get away with pretending it's that.

			regards, tom lane

Re: Mac OS Roman import?

От:
Scott Ribe <scott_ribe@killerbytes.com>
Дата:
> Maybe iconv knows about it?

On OS X it definitely does; on other platforms it may not since supported
encodings are platform-dependent.

-- 
Scott Ribe
scott_ribe@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


Re: Mac OS Roman import?

От:
Christophe Pettus <xof@thebuild.com>
Дата:

On Oct 19, 2009, at 4:39 PM, Scott Ribe wrote:
> On OS X it definitely does; on other platforms it may not since  
> supported
> encodings are platform-dependent.

The Centos version knows about it as well; thanks, that's the perfect  
solution.

--
-- Christophe Pettus
    xof@thebuild.com

FAQ