In Java, I want to print a label with a String as the input:
String command
= "N\n"
+ "A50,5,0,1,2,2,N,\"" + name + "\"\
+ "P1\n";
But when the input (name
) has a double quote character ("
), it is blank and prints nothing. I have tried using the replace function:
name.replace('"', '\u0022');
but it doesn't work. I want that double quote printed in label, how can I do this?
Couple of points:
replace method returns back string after replacing so you should expect something like:
quote has special meaning and hence needs to be escaped in Java. You need the following: