delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/09/28/06:58:40

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
To: cygwin AT cygwin DOT com
From: Robert Schmidt <rschm AT broadpark DOT no>
Subject: Re: file conversion utility sought: from isolatin (8859-1) to utf8
Date: Tue, 28 Sep 2004 12:57:49 +0200
Lines: 37
Message-ID: <415943AD.6030000@broadpark.no>
References: <E1CCF31-0005vJ-00 AT deer DOT gmane DOT org>
Mime-Version: 1.0
X-Complaints-To: usenet AT sea DOT gmane DOT org
X-Gmane-NNTP-Posting-Host: dhcp-068-039.oslo.eur.slb.com
User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913)
In-Reply-To: <E1CCF31-0005vJ-00@deer.gmane.org>
X-IsSubscribed: yes

Ralf Hauser wrote:
> Hi,
> 
> Are there any tools like d2u or u2d for UTF-8 for cygwin?
 > ...
> 
> A starting point might be
> http://userpage.fu-berlin.de/~ram/pub/pub_kfd8tk88g/perl_unicode_en ?

Not particularly cygwin related, but anyway...
This is a better start:
http://www.perldoc.com/perl5.8.0/lib/Encode.html

   #!/usr/bin/perl
   # iso2utf8.pl
   use Encode;

   while(<STDIN>){
     print encode("utf8", decode("iso-8859-1", $_));
   }

Then

   #!/bin/sh
   mkdir -p utf8
   for FILE in $* ; do iso2utf8.pl < $FILE > utf8/$FILE ; done

If you're sure you want in-place, finish off with

   mv utf8/* .

If you need to handle a hierarchy of files, you need to fiddle with find 
  -print0 | xargs -0, or keep it all in perl.  I'm not a perl wiz,


Cheers,
Rob


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019