• 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: Reversing a String
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reversing a String


  • Subject: Re: Reversing a String
  • From: Ricky Sharp <email@hidden>
  • Date: Wed, 31 Dec 2008 12:09:02 -0600


On Dec 31, 2008, at 10:52 AM, Michael Ash wrote:

The key is the usage of -rangeOfComposedCharacterSequenceAtIndex:.
Without calling this method or doing the equivalent to what it does,
your code will suffer the problems I described above.

I tested that code with the string @"abcdéf𝄞g" (that's an accented e
using a combining diacritical before the f, and the aforementioned
musical note at the end) and it worked as expected.


I don't guarantee that my code will work on everything. Unicode is
weird enough and covers enough weird languages that there are probably
situations where this will still fail. But it covers most of the
tricky bits, and at least will always produce valid unicode output.


Reversing a string only really makes sense for certain languages anyhow. Perhaps even just English. The rendering of reversed strings may also get a bit weird for text involving positional variants.

Anyhow, attempting to construct a universal solution will either be too difficult or perhaps not possible. The original poster should provide some extra clues as to what the output will be used for.

I'm all for 100% Unicode support by applications, but there are some situations where working with plain 'ol ASCII still makes sense. In that specific case, reversing a string becomes trivial.

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com



_______________________________________________

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: 
 >Reversing a String (Gabe Shahbazian) (From: Peter Hudson <email@hidden>)
 >Re: Reversing a String (Gabe Shahbazian) (From: "Michael Ash" <email@hidden>)
 >Re: Reversing a String (From: Dave DeLong <email@hidden>)
 >Re: Reversing a String (From: "Michael Ash" <email@hidden>)

  • Prev by Date: Re: Storing NSDocument data in packages/bundles
  • Next by Date: Re: Storing NSDocument data in packages/bundles
  • Previous by thread: Re: Reversing a String
  • Next by thread: Automatically filling an app with test data
  • Index(es):
    • Date
    • Thread