OSProcess reading utf8 files

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

OSProcess reading utf8 files

fstephany
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

Reply | Threaded
Open this post in threaded view
|

Re: OSProcess reading utf8 files

David T. Lewis
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


Reply | Threaded
Open this post in threaded view
|

Re: OSProcess reading utf8 files

fstephany

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