Problem writing some strings (UnicodeEncodeError)

Paulo da Silva p_s_d_a_s_i_l_v_a at netcabo.pt
Sun Jan 12 14:41:01 EST 2014


> 
> I think instead of the hard way sketched out above it will be sufficient to 
> specify the error handler when opening the destination file
> 
> shf = open(bashfilename, 'w', errors="surrogateescape")
This seems to fix everything!
I tried with a small test set and it worked.

> 
> but I have not tried it myself. Also, some bytes may need to be escaped, 
> either to be understood by the shell, or to address security concerns:
> 

Since I am puting the file names between "", the only char that needs to
be escaped is the " itself.

I'm gonna try with the real thing.

Thank you very much for the fixing and for everything I have learned here.




More information about the Python-list mailing list