Hi,

$IN->param is a GT::CGI (basically CGI.pm)

I also tried using

use utf8;

..and:

use Encode qw(encode decode);

..but that converts it into even weirder text:

IMAGE BEFORE: $VAR1 = '00001ËéêèëÏÌÎï whatever.jpg';
IMAGE AFTER: $VAR1 = "00001\x{cb}\x{e9}\x{ea}\x{e8}\x{eb}\x{cf}\x{cc}\x{ce}\x{ef}_whatever.jpg";

Any other ideas?

BTW, as I said before - in the same script - it works fine for other functions - just not this one.

Here is the full function, if it may help:

sub MakeThumb { # print $IN->header; # print "FOO"; my ($id,$field,$table,$size,$key_field) = @_; if (!$id || !$field || !$table || !$size) { use Data::Dumper; return qq|ERROR: Please pass in ALL values (ID, field, table a +nd size) - got "$id","$field","$table","$size"| . Dumper(@_); } ## NEW STUFF # fix the image, so we convert things like accented charachters to + plain charachters # rename_file_with_odd_charachters(filename,table,field,id) my ($img) = $IN->param($field) =~ m|([^\\/]+)$|; # grab the i +mage name...and then assign the path... use Data::Dumper; print "IMAGE BEFORE: " . Dumper($img); # my $img = '00001ËéêèëÏÌÎï whatever.gif'; print STDERR "\n\n$img\n\n"; # $img = decode("utf-8",$img); $img =~ tr{ÀÂÄàâäÇçÉÊÈËéêèëÏÌÎïìîÖÔÒöôòÜÛÙüûùA-Z?!;«»()" }{aa +aaaacceeeeeeeeiiiiiioooooouuuuuua-z__________}; print "IMAGE AFTER: " . Dumper($img); print $IN->header; print qq|XXX: $img,$table,$field,$id <Br />|; rename_file_with_odd_charachters_other($img,$table,$field,$id +); ## END NEW STUFF # get the actual path to where the file is/will be saved... my $schema = $DB->table($table)->cols; my $path = $schema->{$field}->{'file_save_in'}; $path =~ s,/$,,; # get rid of trailing / at end of $path # now we have the highest ID, lets get the image stuff for thi +s link. my $col = $field; # column name where file is held my $tbl = $DB->table( $table ); my $fh = $tbl->file_info( $col, $id ); # return a glob refere +nce to the file that you can print <$fh> if you want my $rel_path; if ($fh) { $rel_path = $fh->File_RelativePath; } # else { # return @args; } undef $fh; # explicit close of the filehandle for good measur +e # create the variable for where the small image will be held... my @img_create = split("/",$rel_path); my $count = $#img_create; my $rel_path_small = undef; # make sure we have this variable + as an undef, otherwise we get probs... for (my $i = 0; $i < $count; $i++) { $rel_path_small .= $img_ +create[$i] . "/"; } $rel_path_small .= "small-" . $img_create[$count]; # create t +he small image name... my $ReadImage = $path . $rel_path; my $WriteImage = $path . $rel_path_small; do_shrink($ReadImage,$WriteImage,$id,$size); return; }


The stuff between

## NEW STUFF

and

## END NEW STUFF

..is where the issue is coming up.

TIA

Andy

In reply to Re^2: tr not working by ultranerds
in thread tr not working by ultranerds

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.