• 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: [SOLVED] Unicode strings in ppc and intel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [SOLVED] Unicode strings in ppc and intel


  • Subject: Re: [SOLVED] Unicode strings in ppc and intel
  • From: Julio Cesar Silva dos Santos <email@hidden>
  • Date: Tue, 27 Jun 2006 11:22:20 -0300

Yes, it is. But I have just fixed it and in the next few hours I will release a new version.

Thanks for replying,

Julio Cesar Silva dos Santos
email@hidden
Blogjective-C
http://www.jcs.santos.nom.br/wp
FetchYourLyrics
http://www.jcs.santos.nom.br/fyl/fyl.html



On 27/06/2006, at 11:04, Dave wrote:

Hola Julio,

Could this be why I get chinese characters when I use your FetchYourLyrics program on my MBP?

Dave

On Jun 27, 2006, at 5:00 AM, Julio Cesar Silva dos Santos wrote:

After reading and thinking (thanks Chris Suter) I guess I found a solution for this problem. Instead of using an NSString to get the value from iTunes, I used a CFString:

CFStringRef myCFString;
#if __BIG_ENDIAN__
myCFString = CFStringCreateWithBytes (kCFAllocatorDefault,myValue,mySize,kCFStringEncodingUnicode,true);
#elif __LITTLE_ENDIAN__
myCFString = CFStringCreateWithBytes (kCFAllocatorDefault,myValue,mySize,kCFStringEncodingUnicode,false);
#endif
myString = (NSString*)myCFString;


Note that the only difference between the calls to CFStringCreateWithBytes is the last parameter, which is a boolean that forces the function to swap bytes when false. This parameter does not exist in [NSString stringWithBytes:]. As Intel based macs are 'Little Endians' the problem now is solved. I do not know if this is the most elegant way to do this but it works.

Julio Cesar Silva dos Santos
email@hidden
Blogjective-C
http://www.jcs.santos.nom.br/wp
FetchYourLyrics
http://www.jcs.santos.nom.br/fyl/fyl.html

Hi,

I am facing a strange problem with an app that I am developing. It retrieves information from iTunes (song name, artist, etc.) and all my tests were successful (I am using a ppc based mac). But some users have reported strange chinese characters showing up even when iTunes displays latin characters. Reviewing the code I am using to retrieve the strings from iTunes it works this way: an NSString is created using initWithBytes method, an Unichar variable as the parameter and NSUnicodeStringEncoding as the encoding.
The users that are complaining use intel-based macs so I think this is a big-endian/little-endian problem. How can I handle this situation? Checking for __BIG_ENDIAN__ and __LITTLE_ENDIAN__ ? I searched the list archives but did not find any useful informartion so any help would be appreciated.
_______________________________________________
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


References: 
 >[SOLVED] Unicode strings in ppc and intel (From: Julio Cesar Silva dos Santos <email@hidden>)

  • Prev by Date: Re: Does NSTextField show placeholder when bound?
  • Next by Date: Re: NSTextField and controlTextDidEndEditing
  • Previous by thread: [SOLVED] Unicode strings in ppc and intel
  • Next by thread: Re: [SOLVED] Unicode strings in ppc and intel
  • Index(es):
    • Date
    • Thread