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

Safe way to convert C String to NSString


  • Subject: Safe way to convert C String to NSString
  • From: Wilker <email@hidden>
  • Date: Thu, 18 Aug 2011 17:02:31 -0300

Hi guys,

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".

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.

What you guys suggest in order that I can convert it to NSString, even
losing non-ascii chars, but keeping others? Or a good way to guess the
encoding and convert property?
---
Wilker LĂșcio
http://about.me/wilkerlucio/bio
Kajabi Consultant
+55 81 82556600
_______________________________________________

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

  • Follow-Ups:
    • Re: Safe way to convert C String to NSString
      • From: Jens Alfke <email@hidden>
    • Re: Safe way to convert C String to NSString
      • From: Howard Siegel <email@hidden>
    • Re: Safe way to convert C String to NSString
      • From: Preston Sumner <email@hidden>
    • Re: Safe way to convert C String to NSString
      • From: David Duncan <email@hidden>
  • Prev by Date: Re: Find a frame of an item in an NSOutlineView?
  • Next by Date: Re: Safe way to convert C String to NSString
  • Previous by thread: Re: Find a frame of an item in an NSOutlineView?
  • Next by thread: Re: Safe way to convert C String to NSString
  • Index(es):
    • Date
    • Thread