|
|
ru.linux- RU.LINUX --------------------------------------------------------------------- From : Kirill Frolov 2:5030/827.2 04 May 2004 14:42:31 To : abrasha shapirus Subject : Re: FIDO SOFT AND BBS -------------------------------------------------------------------------------- On Sat, 01 May 04 18:31:08 +0400, abrasha shapirus wrote: as> посему: а) убрать нафиг настройку перекодировки из конфига hpt; б) пойти в as> ru.golded и почитать в faq, как настраивается перекодировка в голдеде. #! /usr/bin/perl $VERSION = "0.1 alpha (2004-04-25T15:07:43+0400)"; use POSIX qw(locale_h); use Getopt::Long qw(:config no_ignore_case); use File::Spec; use Text::Iconv; Text::Iconv->raise_error(0); $progname=(File::Spec->splitpath($0))[2]; $unk_char='?'; GetOptions( 'target-dir|d=s' => \$out_dir, 'local-encodings|e=s' => \$loc_enc, 'import-encodings|i=s' => \$in_enc, 'export-encofings|o=s' => \$out_enc, 'external-encodings|x=s' => \$ext_enc, 'unknown-char|c=s' => \$unk_char, 'list-charsets|l|L' => sub { exec "iconv -l" }, 'version|v' => sub { print <<END $progname -- Charset mapping tables generator for GoldED $VERSION Copyright (C) 2004 Kirill Frolov. All rights reserved. Program can be freely distributed in modified or umodified form. END ; exit; }, 'help|h' => sub { print <<END Charset mapping tables generator for GoledED $VERSION Usage: $progname -d output-directory -i|-o|-x export-encoding(s) [-options...] Options: -d, --target-dir=<directory> set output directory, this is mandratory option. -e, --local-endodings=<encoding-list> set local encoding(s) (see XLATLOCALSET option in golded.cfg), if not specified locale encoding will be used instead. -i, --import-encodings=<encoding-list> define import-only encoding(s) -o, --export-encodings=<encoding-list> define output-only encoding(s) -x, --external-encodings=<encoding-list> define encodings for both import and export (this option you need in common case) At least one of -x, -o or -i option must be specified. -c, --unknown_char=<char> define replacement for character not existing in output encoding. Only single character can be specified. By default an question sign ('?') will be used. -L, --list-charsets print list of encodings supported by iconv(1) -v, --version print program version and copyright -h, --help show usage information Note on encoding-list specification: encoding-list consist of single iconv(1) encoding name, or multiple encoding names delimited by space, comma or colon. Example: following command line builds charset mapping tables for unix version of GoldEd. $progname -d /usr/share/golded -x "CP866,CP1251,ISO-8859-5" -l "KOI8-R" END ; exit; } ); die "$progname: invalid argument" if ($#ARGV>=0); die "$progname: output directory not specified" unless defined $out_dir; die "$progname: invalid --unknown-char option specification ('$unk_char')" unless (length($unk_char)==1); sub split_enc { split '[,:; \t]', $_[0] }; @in_enc=(split_enc($in_enc), split_enc($ext_enc)); @out_enc=(split_enc($out_enc), split_enc($ext_enc)); @loc_enc=split_enc($loc_enc); if ($#loc_enc<0) { $loc_enc=setlocale('LC_CTYPE'); $loc_enc=~s/^.+\.(.+)$/$1/ || die "$progname: can't determine locale encoding"; @loc_enc=($loc_enc); } die "$progname: no import-export encodings specified" if ($#in_enc==-1) && ($#out_enc==-1); sub mktable($$) { my ($from, $to)=($_[0], $_[1]); return if ($from eq $to); my $iconv=Text::Iconv->new($from, $to); unless (defined $iconv) { # XXX program dies on new() :-( warn "$progname: iconv failed ($from -> $to)"; return; } my $fname=File::Spec->join($out_dir, $from.'_'.$to); open(outf, '>'.$fname) || die "$progname: $fname: $!"; print outf <<END ; id 0 ; version 0 ; level 2 ; ; from charset $from ; to charset $to ; END ; for ($x=0x80; $x<=0xff; $x+=1) { my $n = $iconv->convert(pack('C', $x)); $n = $unk_char unless defined $n; printf outf "\\0 \\x%2.2x\n", unpack('C', $n); } print outf "END\n"; close outf; } map { my $loc_enc=$_; map { mktable($_, $loc_enc) } @in_enc; map { mktable($loc_enc, $_) } @out_enc; } @loc_enc; --- [ZX] * Origin: 0D00 1E54 41D1 9753 3F41 40F7 4BBA 050B 30E8 0E4E (2:5030/827.2) Вернуться к списку тем, сортированных по: возрастание даты уменьшение даты тема автор
Архивное /ru.linux/38336dc81598.html, оценка из 5, голосов 10
|