From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/15339 Path: main.gmane.org!not-for-mail From: "Thomas A. Schmitz" Newsgroups: gmane.comp.tex.context Subject: Re: Perl scripting (was: Arabic-utf-8) Date: Sun, 06 Jun 2004 23:28:05 +0200 Sender: ntg-context-admin@ntg.nl Message-ID: <1086557285.6599.16.camel@tascomputer.home> References: <3960A2BA-B799-11D8-B99E-0030659899AA@fiee.net> Reply-To: ntg-context@ntg.nl NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1086557643 26173 80.91.224.253 (6 Jun 2004 21:34:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 6 Jun 2004 21:34:03 +0000 (UTC) Original-X-From: ntg-context-admin@ntg.nl Sun Jun 06 23:33:56 2004 Return-path: Original-Received: from ref.vet.uu.nl ([131.211.172.13] helo=ref.ntg.nl) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BX5HA-0007Zb-00 for ; Sun, 06 Jun 2004 23:33:56 +0200 Original-Received: from ref.ntg.nl (localhost.localdomain [127.0.0.1]) by ref.ntg.nl (Postfix) with ESMTP id A945510B32; Sun, 6 Jun 2004 23:33:52 +0200 (MEST) Original-Received: from mailout06.sul.t-online.com (mailout06.sul.t-online.com [194.25.134.19]) by ref.ntg.nl (Postfix) with ESMTP id E408B10ABD for ; Sun, 6 Jun 2004 23:31:23 +0200 (MEST) Original-Received: from fwd00.aul.t-online.de by mailout06.sul.t-online.com with smtp id 1BX5Eh-0001ev-03; Sun, 06 Jun 2004 23:31:23 +0200 Original-Received: from [192.168.0.2] (bLhqxTZAZeRm97KhewmLRGbz7RGQcC63mYJ4CH-rcUJ7wvjSBJr0sP@[80.128.255.188]) by fmrl00.sul.t-online.com with esmtp id 1BX5EX-0CMvOy0; Sun, 6 Jun 2004 23:31:13 +0200 Original-To: ntg-context@ntg.nl In-Reply-To: X-Mailer: Ximian Evolution 1.4.6 X-Seen: false X-ID: bLhqxTZAZeRm97KhewmLRGbz7RGQcC63mYJ4CH-rcUJ7wvjSBJr0sP@t-dialin.net Errors-To: ntg-context-admin@ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.0.13 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.comp.tex.context:15339 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:15339 Well, if you put the use open ':utf8'; in the header of your perl script, it should work without the hex editor (btw: I would recommend using emacs in hex mode (M-x hexl-find-file). And just for the record: to put the entire file in one array, use this: my @lines = <>; my $text = join "", @lines; $text =~ s/PUT_YOUR/SUBSTITUIONS_HERE/esg; But it looks like you got a working solution now, so have fun playing around with it. And boy does it make one feel good when you realize that you windoze people are still working with perl 5.6 -- that's the stone age, man ;-) Best Thomas On Sun, 2004-06-06 at 23:03, Idris Samawi Hamid wrote: > On Sun, 6 Jun 2004 11:09:32 +0200, Henning Hraban Ramm > wrote: > > > ----- > > > > #!/usr/bin/perl -w > > use strict; > > use warnings; > > > > my ($Source, $Target) = (shift, shift); # gets 2 file names from command > > line > > > > my %conv = ( # enhance as needed > > "\xD8xA7" => "A", > > "\xD8xA8" => "b", > > "\xD8xAC" => "j", > > "\xD8xAF" => "d" > > ); > > > > open SOURCE, "<", $Source || die $!; > > open TARGET, ">", $Target || die $!; > > # there are ways to read a whole file in one scalar, > > # e.g. with File::Slurp, but I don't know them by heart... > > while (my $line = ) { > > foreach my $key (keys %conv) { > > $line =~ s/$key/$conv{$key}/g; > > } # foreach > > print TARGET $line; > > } # while > > close SOURCE; > > close TARGET; > > > > ----- > > Thnx; I'll play around with this as well. BTW: is there any way to do this > without the hex editor and just enter the full 4-digit character (a la > Thomas's original suggestion) e.g., > > "\x0627" => "A" > > While the hex editor certainly works it is really slow and tedious work... > > > BTW: ActiveState has Perl 5.8.4, at least for Windows (I use it at work). > > Ok, I found it: > > http://downloads.activestate.com/ActivePerl/Windows/5.8/ActivePerl-5.8.3.809-MSWin32-x86.zip > > But the web site (at first glance) sure gives one the impression that > their latest release is > 5.6.1.638 > > http://www.activestate.com/ > > http://www.activestate.com/Products/ActivePerl/ > > Best > Idris > >