Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone ($4.99)

dotnetIQ ($4.99)

Your First iPhone App ($1.99)

iPocket Tools 9 in 1 ($0.99)

Catch-Me (Free)

Alien Strike ($0.99)

Historic Olympic Medal-Table ($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-21-2009, 02:21 PM   #1 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 130
Default how to get UTF-16 from NSString

I have a line of code:

const char *cStr = [clearText UTF8String];

and I want to get the utf16string instead, but can't find an easy way to do this. I know NSString uses UTF-16 internally so I can't figure why this is so difficult.
john855 is offline   Reply With Quote
Old 01-21-2009, 02:35 PM   #2 (permalink)
New Member
 
RickMaddy's Avatar
 
Join Date: Oct 2008
Location: Denver, CO
Posts: 2,121
Default

It's not difficult.

Code:
const char *cStr = [clearText cStringUsingEncoding:NSUnicodeStringEncoding];
Note: You may need NSUTF16BigEndianStringEncoding or NSUTF16LittleEndianStringEncoding instead of NSUnicodeStringEncoding.
RickMaddy is offline   Reply With Quote
Old 06-25-2009, 12:22 PM   #3 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 14
Default

can you please tell the difference between :

NSUTF16BigEndianStringEncoding, NSUTF16LittleEndianStringEncoding and NSUnicodeStringEncoding


I am trying to port a windows code, which was actually using WCHARs.

TIA
Vibhor
vibhorgoyal is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


» Advertisements
» Stats
Members: 21,496
Threads: 35,780
Posts: 156,745
Top Poster: smasher (2,448)
Welcome to our newest member, GarLe722
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:27 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0