Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to escape double quotes in string?

I'd like double quotes to appear within the following string so it looks like:

"hi there == "

Here's the code I'm using:

NSMutableString *s = [[NSMutableString alloc] init];
[s appendString:@""""];
[s appendString:@"hi there == ""\n\r"];

Instead I only get:

hi there ==

Any ideas?

like image 511
4thSpace Avatar asked Aug 29 '09 20:08

4thSpace


People also ask

How to escape double quotes from a string in Java?

There are scenarios where you need to escape double quotes already present in the String. This generally happens while dealing with JSON file format or reading file data. Double quotes characters can be escaped with backslash ( \) in java.

Is it possible to escape a double quote character in SSIs?

The old Access version 'knows' that when a double quote character appears in the middle of a string, it needs to be escaped, i.e., displayed as "", so as not to be mistaken for the ending string delimiter, but I can not reproduce this desired behaviour in the SSIS version.

How to escape double quotes in a template literal?

You can escape double quotes (or any special character) using a slash ( \ ) const slashEscape="It was the last step."Stop!". She shouted." Inside a template literal, you don't have to escape single or double-quotes. const templateLiteral=`"I'm OK with this Agreement" Said he. "Me too!". I said.`

How to escape a quote in a string in Python?

Put the escaping character before the single quote in the string. You can use the first solution like this: In Python, the backslash is an escaping character. So you can use it like the below: Now suppose you have to print the below line: She said, “You are looking nice”. And I smiled print ("She said, "You are looking nice". And I smiled")


2 Answers

[s appendString:@"hi there == \"\n\r"];

\" is what is needed for " - This is standard C formatting.

like image 171
mmmmmm Avatar answered Sep 29 '22 11:09

mmmmmm


Although Its late but we can Try this:

[NSString stringWithFormat:@"\"Hi There=\" Other text"];
like image 33
Amit Ajmera Avatar answered Sep 29 '22 13:09

Amit Ajmera