From: Mattia B. <mat...@li...> - 2007-06-19 20:16:00
|
On Sat, 12 May 2007 16:40:05 +0100 Mark Dootson <mar...@zn...> wrote: Hi, > I have a problem with module Wx::Perl::ProcessStream. > This reads the STDOUT from an external process executed using Wx::Process and Wx::ExecuteCommand. > > To do this it, it does a 'readline' on the wxInputStream available via Wx::Process. > > My problem is that the implementation of READLINE in Wx::InputStream works as follows: > > read a char from the stream > append char to a wxString > return wxString if char == '\n' > > > This appears not to work if the output stream from the external process is, for example, UTF-8. > > I *think* what perhaps should happen is > > read a char from the stream > add it to a charbuffer > if char == '\n' { > convert charbuffer to a wxString ( method determined by wxWidgets unicode/ansi build macros ) > return wxString > } I do not agree with what you write above (note: I am not saying the current implementation is correct!) what I think readline should do is work with bytes: read a char from the stream add it to a charbuffer if char == '\n' { return the buffer as a byte string, without performing any conversion } I believe that automatically interpreting program output based upon wxWidgets ideas (which usually means using the current locale) will cause trouble. Returning bytes leaves the interpretation to the calling program which is always a safe choice. Regards Mattia |