• 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: NSUTF8StringEncoding problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSUTF8StringEncoding problems


  • Subject: Re: NSUTF8StringEncoding problems
  • From: Clark Cox <email@hidden>
  • Date: Fri, 11 Mar 2005 15:37:55 -0500

On Fri, 11 Mar 2005 11:39:32 -0800, Dustin Voss <email@hidden> wrote:
> On 11 Mar, 2005, at 2:17 AM, Rakka wrote:
>
> > I am appending the output of an NSTask (NSData) into a textview with
> > the following code, and it works perfectly fine for "normal" text, but
> > if the output contains non-english characters, such as japanese, wierd
> > things are displayed.
> >
> > NSString *inText = [[NSString alloc] initWithData:inData
> > encoding:NSASCIIStringEncoding];
> >
> > [logField replaceCharactersInRange:textEnd withString:inText];
> >
> > I tried changing NSASCIIStringEncoding to NSUTF8StringEncoding, but
> > then an exception is raised saying withString is nil, whenever
> > non-english characters were in the output.
> >
> > Is there any way I can make the incoming data UTF8 without errors so I
> > can append it to the textview?
>
> The NSTask output is already in an encoding: the encoding used by
> command-line apps. You can get that encoding by using [NSString
> defaultCStringEncoding].

Those are not the same. On my machine, for instance, the
defaultCStringEncoding is MacRoman, while, in general, command line
apps use UTF-8. To the OP, you'll just have to find out what encoding
the data is already in.

--
Clark S. Cox III
email@hidden
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSUTF8StringEncoding problems
      • From: Rakka <email@hidden>
References: 
 >NSUTF8StringEncoding problems (From: Rakka <email@hidden>)
 >Re: NSUTF8StringEncoding problems (From: Dustin Voss <email@hidden>)

  • Prev by Date: Re: Where's the list box?
  • Next by Date: Re: Could not connect the action to target of class
  • Previous by thread: Re: NSUTF8StringEncoding problems
  • Next by thread: Re: NSUTF8StringEncoding problems
  • Index(es):
    • Date
    • Thread