• 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: Safe way to convert C String to NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Safe way to convert C String to NSString


  • Subject: Re: Safe way to convert C String to NSString
  • From: David Duncan <email@hidden>
  • Date: Thu, 18 Aug 2011 13:08:50 -0700

On Aug 18, 2011, at 1:02 PM, Wilker wrote:

> I'm having some trouble by trying to convert a C String to NSString, I'm currently using:
>
> NSString *mystring = [NSString stringWithUTF8String:cstring];
>
> But I don't know which encoding the string is using... And when it has some latin or other kind of characteres, the return is "nil".

Where is the string coming from? Typically the source indicates the encoding in some way.

> In my case I really don't care about these characters, if I can just remove non-ascii from C String and them convert to NSString will be fine for me.

Thats not always viable. Consider that in MacRoman most of the accented characters use code points in the range of 128-255, and just removing them can make the text look incredibly wrong.
--
David Duncan

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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

References: 
 >Safe way to convert C String to NSString (From: Wilker <email@hidden>)

  • Prev by Date: Safe way to convert C String to NSString
  • Next by Date: Re: Safe way to convert C String to NSString
  • Previous by thread: Safe way to convert C String to NSString
  • Next by thread: Re: Safe way to convert C String to NSString
  • Index(es):
    • Date
    • Thread