I'm trying to implement a CSV parser. Suppose I have an input string "a, a'b, c, d'c, b"
, and output should be a list of strings: "a"
, "a'b, c, d'c"
, "b"
. So basically it means all chars between ''
should be a part of one string. The problem I am facing is that when I scan the input string, I cannot check if the char is '
, because if(c==''')
is invalid, because '
is an invalid character constant. So how should I check if a char in the input string is '
?
Asked
Active
Viewed 115 times
1
-
2genarally special characters need to be escaped with a \ in front of them – HopefullyHelpful Dec 17 '15 at 01:24
-
http://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.10.6 – user1803551 Dec 17 '15 at 01:27
2 Answers
0
You need to escape the special character '
with a \
. Take a look at the java documentation for more information.
b
should be equal to true
after executing this:
Character charValue = '\'';
boolean b = (charValue == '\'');

Cacho Santa
- 6,846
- 6
- 41
- 73