• 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: does NSTextField always use UTF8 encoding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: does NSTextField always use UTF8 encoding


  • Subject: Re: does NSTextField always use UTF8 encoding
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 18 Jun 2008 07:08:48 -0500

On Jun 18, 2008, at 1:25 AM, Andrew Farmer wrote:

On 17 Jun 08, at 23:16, Wayne Shao wrote:
In my UI, a user may type in any string into a NSTextField, e.g.
Chinese characters.

Do I assume the return value from

NSString * value = [textField stringValue]

is always encoded with UTF8?

NSStrings are encoding-independent. They represent strings, not sequences of bytes.


I need to convert this to a properly url encoded value as a GET parameter.

[value stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] will return a string with proper UTF-8 percent escaping.

And if you want to get a byte sequence in a particular encoding from a string, you can use one of:


-[NSString cStringUsingEncoding:]
-[NSString getCString:maxLength:encoding:]
-[NSString dataUsingEncoding:allowLossyConversion:]
-[NSString UTF8String]

Cheers,
Ken
_______________________________________________

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: 
 >does NSTextField always use UTF8 encoding (From: "Wayne Shao" <email@hidden>)
 >Re: does NSTextField always use UTF8 encoding (From: Andrew Farmer <email@hidden>)

  • Prev by Date: Running a daemon
  • Next by Date: Re: Running a daemon
  • Previous by thread: Re: does NSTextField always use UTF8 encoding
  • Next by thread: Re: does NSTextField always use UTF8 encoding
  • Index(es):
    • Date
    • Thread