Article View: pl.comp.lang.perl
Article #39898Re: Podmiana znakow w stringu
From: vellezz
Date: Tue, 02 Nov 2004 16:32
Date: Tue, 02 Nov 2004 16:32
42 lines
2608 bytes
2608 bytes
Użytkownik "vellezz" <vellezz@polbox.com> napisał w wiadomości
news:cm8bvg$8aj$1@nemesis.news.tpi.pl...
> string:Bagażnik 16" niklowany
> HEX:42616761bf6e696b20313622206e696b6c6f77616e79
> ASCII:669710397191110105107324954343211010510710811111997110121
#!/usr/bin/perl -w
use DBI;
#use strict;
# pobranie danych z pliku dbf
my $dbh = DBI->connect('dbi:XBase:/home/romed/Subiekt4/dbfs',undef , undef,
{RaiseError => 1}) or die DBI->errstr;
my $data = $dbh->selectall_arrayref(q!select * from towary.dbf!,
{MaxRows=>'10'}) or die $dbh->errstr;
$dbh->disconnect();
# konwersja strony kodowej
my @dos_852 =
('a4','8F','a8','9d','e3','e0','97','8d','bd','a5','86','a9','88','e4','a2',
'98','ab','be');
my @iso8859_2 =
('a1','c6','ca','a3','d1','d3','a6','ac','af','b1','e6','ea','b3','f1','f3',
'b6','bc','bf');
for $i (0..($count=@dos_852-1)){
$iso8859_2[$i] = pack "H*",$iso8859_2[$i];
$dos_852[$i] = pack "H*",$dos_852[$i];
}
for $i (0..($count=@$data-1)) {
for $j (0..($count=@dos_852-1)) { #wymiana znakow w stringu z nazwa
$data->[$i]->[2] =~ s/$dos_852[$j]/$iso8859_2[$j]/eg;
$data->[$i]->[2] =~ s/\'/\"/; # zmiana ' na "
$data->[$i]->[2] =~ s/"/\\\"/g; # <<<<< coś z tym jest nie tak
}
}
A to jest efekt zastosowania s/"/\\\"/g
string:Bagażnik 16\\\\\\\\\\\\\\\\\\" niklowany
HEX:42616761bf6e696b2031365c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c5c22206e696b6c6f
77616e79
ASCII:6697103971911101051073249549292929292929292929292929292929292923432110
10510710811111997110121
Technical Details
Message-ID:
<cm8cu7$ch2$1@nemesis.news.tpi.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mailReferences:
<cm86gs$f7q$1@atlantis.news.tpi.pl> <Xns9595A33B95EEAelhber1lidotechnet@62.89.127.66> <cm88ku$qsn$1@atlantis.news.tpi.pl> <Xns9595A97065151elhber1lidotechnet@62.89.127.66> <cm8bvg$8aj$1@nemesis.news.tpi.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail From: "vellezz" <vellezz@polbox.com> Newsgroups: pl.comp.lang.perl Subject: Re: Podmiana znakow w stringu Date: Tue, 2 Nov 2004 17:32:16 +0100 Organization: tp.internet - http://www.tpi.pl/ Lines: 45 Message-ID: <cm8cu7$ch2$1@nemesis.news.tpi.pl> References: <cm86gs$f7q$1@atlantis.news.tpi.pl> <Xns9595A33B95EEAelhber1lidotechnet@62.89.127.66> <cm88ku$qsn$1@atlantis.news.tpi.pl> <Xns9595A97065151elhber1lidotechnet@62.89.127.66> <cm8bvg$8aj$1@nemesis.news.tpi.pl> NNTP-Posting-Host: akk21.neoplus.adsl.tpnet.pl X-Trace: nemesis.news.tpi.pl 1099413255 12834 83.26.14.21 (2 Nov 2004 16:34:15 GMT) X-Complaints-To: usenet@tpi.pl NNTP-Posting-Date: Tue, 2 Nov 2004 16:34:15 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit