--- mail2lj/mail2lj.pl 2007/08/14 04:19:50 1.4 +++ mail2lj/mail2lj.pl 2007/08/14 05:38:33 1.5 @@ -207,7 +207,13 @@ if ( exists $Opt{'comments'} ) { # with other parameters. $Opt{'prop_taglist'} = join( ", ", @opt_taglist ) if ( @opt_taglist ) ; -# Convert all command line options to unicode. +# Convert $opt_ljcut_text to UTF8. +if ( defined $opt_ljcut_text ) { + $opt_ljcut_text = + to_utf8({ -string => $opt_ljcut_text, -charset => $SystemCharset }) ; +} + +# Convert all %Opt command line options to unicode. # Function href2utf8() uses a reference to input hash, so %Opt is # being modified "in-place". href2utf8( \%Opt, $SystemCharset) ; @@ -604,8 +610,18 @@ sub post_me2req { # Changed by LG - added options to add the 'From' field to the # posted message. + # + # NOTE: $from is already in UTF8. Strictly speaking, everything + # that we add to it MUST ALSO BE IN UTF8 (i.e. you need to run + # a to_utf8() function on it). But since all I'm adding is in + # ISO-8859-1 lower ASCII characters (which are guaranteed to + # have the same values in UTF8 as in plain ISO-8859-1), I'm + # cheating here and taking a shortcut. If you want to add + # something non-ASCII, you MUST convert it to UTF8 first! + # Be forewarned! if ( $opt_addfrom ) { $hr->{event} = "From: $from" . "\n\n" . $hr->{event} ; + $hr->{event} = $plain_from . $hr->{event} ; } elsif ( $opt_addfromh ) { my $html_from = "From: $from" ; $html_from =~ s/\@/[_\@_]/g ;