• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSString encoding and perl script encoding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString encoding and perl script encoding


  • Subject: Re: NSString encoding and perl script encoding
  • From: Chris Ridd <email@hidden>
  • Date: Thu, 01 Feb 2007 16:15:26 +0000
  • Thread-topic: NSString encoding and perl script encoding

On 1/2/07 3:34, "David Brennan" <email@hidden> wrote:

> Hi,
>
> I am sending text from my NSString to a perl script using a NSPipe,
> and I'm trying to read the result from the script using a pipe. When I
> send the text I use the encoding NSUTF8StringEncoding to create a
> NSData object. When I read the result from the pipe, I also use
> NSUTF8StringEncoding to convert the NSData to NSString.
>
> At the start of my script I tell it to use 'utf8', see below.
>
> But when I try to create the NSString from the NSData that is sent
> back from the script, it fails. It seems that the encoding is
> incorrect.
>
> I am working on Tiger. What encoding should I use?
>
> Thanks,
> Dave.
>
> use encoding 'utf8';
>
> while (defined($line = <STDIN>))
> {
>     print $line
> }

A somewhat superficial glance at 'man perlunicode' suggests that "use
encoding 'utf8'" really just changes the way your script is encoded. If you
want to change how STDIN is interpreted, you need to do something like (see
"man perlfunc"):

    binmode STDIN, ":utf8";

A similar call would be required for STDOUT. But a careful read of the above
manpages is recommended :-)

Cheers,

Chris


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSString encoding and perl script encoding
      • From: Sherm Pendley <email@hidden>
References: 
 >NSString encoding and perl script encoding (From: "David Brennan" <email@hidden>)

  • Prev by Date: NSString encoding and perl script encoding
  • Next by Date: How to get deviceDeltaX/Y from NSScrollWheel..?
  • Previous by thread: NSString encoding and perl script encoding
  • Next by thread: Re: NSString encoding and perl script encoding
  • Index(es):
    • Date
    • Thread