Say I have an NSString (or NSMutableString) containing:

I said "Hello, world!".
He said "My name's not World."

What's the best way to turn that into:

I said \"Hello, world!\".\nHe said \"My name\'s not World.\"

Do I have to manually use -replaceOccurrencesOfString:withString: over and over to escape characters, or is there an easier way? These strings may contain characters from other alphabets/languages.

How is this done in other languages with other string classes?

Edit
Report