perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luiz Fernando Bernardes Ribeiro <l...@engenhosolucoes.com.br>
Subject Re: Problem with file upload
Date Tue, 30 Sep 2008 14:37:07 GMT
Hello JC,

Try to set your locale inside your Embperl file, try:

[-
use locale;
-]

just before your upload code, and if this doesn't help try changing the 
locale for this file with the POSIX module:

[!
use POSIX qw(locale_h);
!]
[-
use locale;
setlocale(LC_ALL, "pt_BR.ISO8859-1");
-]

Change pt_BR to your locale.
See man setlocale for more info.


Hope it helps.

Regards,

--
Luiz Fernando Bernardes Ribeiro
Engenho Soluções
Tel: +55 11 2122-4216
Cel: +55 11 9254-1061	

Jean-Christophe Boggio escreveu:
> Hello,
> 
> I have a fully UTF8 encoded site in which I want users to upload files
> (simple <input type="file...> form).
> These files are ISO-8859-1 encoded.
> 
> My problem is that sometimes the file is correctly uploaded and
> sometimes it is converted to something stupid :
> 
> ==>correct :
> $ hd sconet1.csv |head -1
> 00000000  4e 6f 6d 3b 50 72 e9 6e  6f 6d 20 31 3b 44 61 74  |Nom;Pr.nom 
> 1;Dat|
> 
> ==>bad :
> $ hd sconet1.csv |head -1
> 00000000  4e 6f 6d 3b 50 72 ef bf  bd 6e 6f 6d 20 31 3b 44  
> |Nom;Pr...nom 1;D|
> 
> The problem seems completely random, sometimes pressing F5 a few times 
> makes
> the upload work.
> 
> The code I use is this :
>         open(FILE,">:encoding(iso-8859-1)","sconet1.csv") or print OUT $!;
>         my $buffer;
>         while (read($fdat{efilename},$buffer,32768)) {
>             print FILE $buffer;
>         }
>         close(FILE);
> 
> I have tried removing the second param to open() but it changes nothing.
> 
> The problem arises in Firefox and IE so I guess the problem is server-side.
> 
> At the beginning of _base.epl I have this :
>     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
> 
> Can I force a "pure binary" upload/save of the file ?
> 
> *any* clue much appreciated. I'm getting mad with this...
> 
> Thanks,
> 
> JC
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message