OSProcess reading utf8 files

classic Classic list List threaded Threaded
3 messages Options
fstephany fstephany
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

OSProcess reading utf8 files

Hi,

Reading an utf8 file with OSProcess results in some weird characters
showing up.

(PipeableOSProcess command: 'less /path/to/a/text/file') output.
-> inspect the bytestring and get some non-ascii characters fucked up.

Doing `less /path/to/a/text/file` in a terminal displays the file fine.

That's probably something stupid on my side but I cannot get it working.
Any idea ?

Cheers,

Francois

David T. Lewis David T. Lewis
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: OSProcess reading utf8 files

On Sat, Nov 19, 2011 at 06:19:59PM -0800, Francois Stephany wrote:

> Hi,
>
> Reading an utf8 file with OSProcess results in some weird characters
> showing up.
>
> (PipeableOSProcess command: 'less /path/to/a/text/file') output.
> -> inspect the bytestring and get some non-ascii characters fucked up.
>
> Doing `less /path/to/a/text/file` in a terminal displays the file fine.
>
> That's probably something stupid on my side but I cannot get it working.
> Any idea ?

Francois,

The output of the PipeableOSProcess is based on a StandardFileStream
rather than a MultiByteFileStream, so it may not do what you expect
with a file containing non-ascii characters.

Note that the unix /usr/bin/less utility is intended for interactive
use with a terminal. You probably should use /usr/bin/cat instead.

HTH,
Dave


fstephany fstephany
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: OSProcess reading utf8 files

Hi Dave,

Ok! I'll try to get it work...

Yep 'less' was an example, I'm actually wrapping the exiftool perl library...

Francois

On Nov 20, 2011 6:30 AM, "David T. Lewis" <[hidden email]> wrote:
On Sat, Nov 19, 2011 at 06:19:59PM -0800, Francois Stephany wrote:
> Hi,
>
> Reading an utf8 file with OSProcess results in some weird characters
> showing up.
>
> (PipeableOSProcess command: 'less /path/to/a/text/file') output.
> -> inspect the bytestring and get some non-ascii characters fucked up.
>
> Doing `less /path/to/a/text/file` in a terminal displays the file fine.
>
> That's probably something stupid on my side but I cannot get it working.
> Any idea ?

Francois,

The output of the PipeableOSProcess is based on a StandardFileStream
rather than a MultiByteFileStream, so it may not do what you expect
with a file containing non-ascii characters.

Note that the unix /usr/bin/less utility is intended for interactive
use with a terminal. You probably should use /usr/bin/cat instead.

HTH,
Dave


Loading...