/[webpac]/trunk/parse_format.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/parse_format.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 293 by dpavlin, Mon Mar 29 19:41:12 2004 UTC revision 488 by dpavlin, Wed Sep 29 17:22:24 2004 UTC
# Line 56  sub parse_iso_format { Line 56  sub parse_iso_format {
56                  my $f = $format;                  my $f = $format;
57    
58                  my $eval;                  my $eval;
59                  $eval = $1 if ($f =~ s/^eval{([^}]+)}//);                  $eval = $1 if ($f =~ s/^eval{([^}]+?)}//);
60    
61                  if ($f =~ s/^([^\d]+)//) {                  if ($f =~ s/^([^\d]+)//) {
62                          if ($f) {       # there is more to parse                          if ($f) {       # there is more to parse
# Line 163  sub parse_iso_format { Line 163  sub parse_iso_format {
163                  sub fld2str {                  sub fld2str {
164                          my ($func,$row,$f,$sf,$i) = @_;                          my ($func,$row,$f,$sf,$i) = @_;
165  #print STDERR "## in fld2str\n";  #print STDERR "## in fld2str\n";
166                          my $tmp = $codepage->convert(&$func($row,$f,$sf,$i)) || '';                          my $tmp = $codepage->convert(&$func($row,$f,$sf,$i)) ||  $codepage->convert(&$func($row,$f,$sf,0)) || '';
167                          return "'$tmp'";                          return "'$tmp'";
168                  }                  }
169    
170                  $eval =~ s/v(\d+)\^(\w*)/fld2str($func,$row,$1,$2,$i)/eg;                  $eval =~ s/v(\d+)\^(\w*)/fld2str($func,$row,$1,$2,$i)/eg;
171  #print STDERR "## eval: $eval\n";  #print STDERR "## eval: $eval\n";
172                  if (eval "$eval") {                  if (eval "$eval") {
173                            die "eval error: eval{$eval}: $@" if ($@);
174                          return ($swish,$display);                          return ($swish,$display);
175                  } else {                  } else {
176                            die "eval error: eval{$eval}: $@" if ($@);
177                          return (undef,undef);                          return (undef,undef);
178                  }                  }
179          }          }
# Line 192  sub parse_excel_format { Line 194  sub parse_excel_format {
194          my $format = shift;          my $format = shift;
195          my $row = shift;          my $row = shift;
196          my $i = shift;          my $i = shift;
197          my $codepage = shift;          #my $codepage = shift;
198            #
199            # data allready comes in utf-8 due to change in
200            # SpreadSheet::ParseExcel::FmtDefault line 69 from
201            #       return pack('C*', unpack('n*', $sTxt));
202            # to following which returns utf-8:
203            #       return pack('U*', unpack('n*', $sTxt));
204            #
205    
206          return if ($i > 0);     # Excel doesn't support repeatable fields          return if ($i > 0);     # Excel doesn't support repeatable fields
207    
# Line 213  sub parse_excel_format { Line 222  sub parse_excel_format {
222  #print STDERR "--$1-> $format -[",length($format),"] ";  #print STDERR "--$1-> $format -[",length($format),"] ";
223                          if ($row->{$1}) {                          if ($row->{$1}) {
224                                  my $tmp = $row->{$1};                                  my $tmp = $row->{$1};
                                 if ($codepage) {  
                                         $tmp = $codepage->convert($tmp) || warn "excel: $1 '$tmp' can't convert";  
                                 }  
225                                  $display .= $prefix . $tmp;                                  $display .= $prefix . $tmp;
226                                  $swish .= $tmp." ";                                  $swish .= $tmp." ";
227  #print STDERR " == $tmp";  #print STDERR " == $tmp";
# Line 224  sub parse_excel_format { Line 230  sub parse_excel_format {
230                  } elsif ($format =~ s/^([^A-Z\|]+)(\|[A-Z]{1,2}\|)/$2/) {                  } elsif ($format =~ s/^([^A-Z\|]+)(\|[A-Z]{1,2}\|)/$2/) {
231                          $prefix .= $1 if ($display);                          $prefix .= $1 if ($display);
232                  } else {                  } else {
233                          print STDERR "unparsed format: $format\n";                          #print STDERR "unparsed format: $format\n";
234                          $prefix .= $format;                          $prefix .= $format;
235                          $format = "";                          $format = "";
236                  }                  }

Legend:
Removed from v.293  
changed lines
  Added in v.488

  ViewVC Help
Powered by ViewVC 1.1.26