Is there a way to use double quotes in a method name, like this?
#Test
fun `should do "something"`() {
// ...
}
It works with ', but not with ". Is there a way to escape double quotes?
(I'm getting a compilation error due to incorrect syntax)
Special characters can be used in method names if escaped with back-ticks.
Your example compiles in my Kotlin project.
But it also depends on the target platform, if compiling to the Android then the set of characters is more restrictive.
See discussion here - https://discuss.kotlinlang.org/t/more-characters-allowed-for-identifiers-than-grammar-specifies-what-is-supported/2359/11
And the grammar definition here - https://kotlinlang.org/docs/reference/grammar.html#Identifier
Related
By default, bracket matching doesn't understand strings and so will match brackets inside of quotes.
Steps to reproduce:
Start the language-configuration-sample extension
Type the following line in the file,
[ "]" ]
Move the cursor to the start of the line and hit Ctrl-\
The open bracket will match with the bracket inside the quotes.
The same behavior happens with anything defined as "brackets" in the config.
I've noticed language extensions like java, python, etc do not have this behavior. How do they get around it? I've looked through their code and haven't seen anything that looks related.
I am working on macOS, not iOS, XCode 11.
My app allows in a specific location to enter text. This text can be anything. Once done it exports a csv which will be passed to an external process i cannot influence.
The issue: the external process uses semicolon ";" as a separator (csv is separated differently). If the user writes semicolon the external process will fail.
If I manually add an escaping backslash before each semicolon to the csv and then pass it to the external app it works.
What I need: having each semicolon escaped with ONE backslash in the final csv
What I tried
Escaping the whole text with quotation marks - fail
Escaping semicolons in objective-c before writing csv by trying
stringByReplacingOccurrencesOfString (look for #";" replace with #"\;" - compiler throws a warning that escape character is unknown - fail
Appreciate any help
UPDATE:
I also tried to set a double backslash like #Corbell mentioned but this leads in a double backslash in the exported CSV -> fail
I also tried to set a single backslash by using its unicode character:
[NSString stringWithFormat:#"%C;",0x5C]; --> "\\;"
Also failed and produces two backslashes in the final CSV (where i need ONE only).
In your stringByReplacingOccurencesOfString call, second parameter, try escaping your backslash with a backslash to make it a literal character to insert, i.e. #"\\;" - otherwise the compiler thinks you're trying to specify #"\;" as an escape sequence (backslash-semicolon) which is invalid.
Solved. It was the CSV Parser that added additional escaping characters. Once solved that it worked like a charm.
I have a string which i am getting
#set($locator=$dataElement.getLocator().get(0))
#set($selector = $locator.getSelector())
$selector is string type and it contains double quotes as well
when i am calling
executor.click(new Params("$selector",BY.$By));
selector have double quotes, which needs to be replaced with single quotes.
i tried with replacing but it is giving error
i referred question
Escaping quotes in velocity template
But this also don't solved my purpose
example
$selector can be something like
a[#href="somelink"]
and i want that to changed to
a[#href='someLink']
For velocity
$selector.replaceAll('"',"'")
replaces " with '
so something like:
executor.click(new Params("$selector.replaceAll('"',"'")",BY.$By));
this works fine
In VB.NET how do I replace special opening and closing double quotes (“ and ”) with ASCII quotes (").
Ive tried
s = s.replace("“", """")
but it seems that Visual Studio consider the “ quote in my code to be a normal quote leaving me with an invalid statement.
Unfortunately VB.NET doesn't support escape sequences but you can use ChrW() to specify code point:
s = s.Replace(ChrW(&H201C), """")
That's for “, code for ” is &H201D. Note that using code points you're free to search & replace any Unicode character (not just what VB.NET has an escape for - like ").
For complete list see: http://unicode-table.com/en/
If you want to use a quotation mark inside a string, VB doesn’t know whether the quotation mark is supposed to end the string or not. In C#, this would be fixed by escaping the quotation mark, i.e. in place of """ you’d write "\"". In VB, the same is done by doubling the quotation mark, i.e. """".
Back to your curly quote. The same as for straight quotes applies according to the VB language specification (¶1.6.4). So to write a curly quote in code, try the following:
s = Replace(s , "““", "“")
a second way: s = Replace(s , ChrW(&H201C), "“")
All of the sudden Xcode is giving me an error "unexpected '#' in program" at the beginning of my object #interface.
This is happening in a bunch of my objects that were previously working...
Here's an example (with errors in comments)
#import <UIKit/UIKit.h>
#import "ONCOChordDiamond.h"
#interface ONCOChordView : UIView //// unexpected '#' in program
{
NSMutableArray* chordDiamonds;
NSUInteger diamondWidth, diamondHeight;
}
#end /////unexpected '#' in program'
So why is Xcode giving me this error? It seems like a bug.
I doubt you're still having the issue, but if you are check the header file. I pasted in code from the web in a class and the quotation marks weren't the standard " ". The marks were stylized with an opening quote and a closing quote because it came from a webpage. Retyping the quote marks fixed it.
You are including the header from a file that is not compiled as Objective C.
Check for syntax errors in the ONCOChordDiamond.h file. They may be highlighted for you if you run Product > Analyze in Xcode.
Importing a file with syntax errors could lead to the compiler not being able to parse the current file correctly, even if the current file's syntax is correct.
When encountering this problem with NSString literals, Check that you have used quotation marks, as required.
(eg. #"myString")
If you find your NSStrings are not correctly syntax coloured, you might check for the following offending characters.
" (QUOTATION MARK)
″ (DOUBLE PRIME)
“ (LEFT DOUBLE QUOTATION MARK)
” (RIGHT DOUBLE QUOTATION MARK)
For what it's worth, I had this issue and the offending line that was identified was nowhere near any string literals.
I did notice that some of the following lines were colored oddly (again, no string literals to blame), so I tested out putting a bogus string literal in the code just before the offending line.
NSString *whatever = #"";
Apparently, it convinced the compiler that the line wasn't screwed up, so it then compiled just fine without complaining. After that build, I was able to delete the bogus string variable and move on with my life.
I had a similar problem and it was because the last quote was getting escaped out. I was using a multiline string with a terminating "\" to eat up the end of line character.
[ string appendFormat:#"\n\
vec4 position;\n\
vec4 inputTextureCoordinate;\n\" ];
After I removed the mistaken "\" that ate up the last quote it worked.