Christopher Barker wrote:
> Michael Droettboom wrote:
>   
>> I think the real reason this wasn't done is that its tricky to do at the 
>> C level in a cross-platform way.  At present it uses the regular POSIX 
>> fopen in C, which isn't really "Unicode aware".
>>     
>
> The actual error is from trying to put the filename in a std::string, 
>   
Presumably because it doesn't decode into ASCII.
> but yes, I'm sure the fopen issue is the driver. Does C++ offer anything 
> better?
>   
Not in the C++ standard library in a cross platform way, that I'm aware 
of.  All three platforms (if you include Gtk, Qt etc.) have special 
Unicode-aware APIs, and each deals with things differently.  The 
approach I took basically leverages all the trouble the Python core guys 
put into to make this work cross-platform.
>    See the "Unicode
>   
>> filenames" section of the link below for some of the complications.  
>> Linux is particularly hard to get right:
>>
>> http://www.amk.ca/python/howto/unicode
>>     
>
> Thanks, that's a good one.
>
>  >  you can do the following as a workaround
>   
>> (with a performance hit from making many Python function calls):
>>
>>   savefig(open(u"CrazyUnicodeFilename.png", "w"))
>>     
>
> thanks, I'll give that a try. I'm confused, though, why the many Python 
> function calls? the C++ code doesn't just grab the file pointer?
>   
No -- a while back, it was segfaulting when trying to do that (but I've 
since figured out why -- it was a reference counting problem).  In 
0.91.2, it calls the "write" method on the Python object for each block 
of PNG data.  SVN still supports that approach (to handle arbitrary 
Python file-like objects), but will extract the real C file handle if it 
is in fact a real file.

Mike

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to