0

I need to decode and encode the MS Office double quote character. I used escape and unescape function in JavaScript to escape the MS Office double quote character but I couldn't use it in Java. How do I do this in Java?

  • MS Office double quote:
  • Double quote got from keyboard: "
Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Manoj
  • 5,707
  • 19
  • 56
  • 86
  • i dont how Stackoverflow differentiate the two double quote character. How it is storing and retrieving the character !! – Manoj May 12 '11 at 10:37

1 Answers1

2

MS Office uses the valid and legitimate Unicode characters U+201C LEFT DOUBLE QUOTATION MARK () and U+201D RIGHT DOUBLE QUOTATION MARK (). Strictly speaking those are more correct, grammatically, than U+0022 QUOTATION MARK (").

Unless you're working with some legacy systems that don't support Unicode strings, replacing them should be trivial (for example using String.replace("“", "\"") in Java).

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
  • You are true. But i would need to do this in javascript. When i tried, replace of left double quote with regular double quote in javascript, nothing gets replaced. – Manoj May 12 '11 at 11:51
  • @Manoj: so are you asking about JavaScript or Java? In any case: post some example code that demonstrates your problem. – Joachim Sauer May 12 '11 at 11:55
  • Sorry, I can't post code. Actually we are using rich text editor called niceditor to get input from user. Everything is working fine for large character set. Recently we got this quote problem. We are stuffing value into JSON objects and we take it to server for processing. So here because of the special quote we are getting null Json object. So we fixed it with escape js function and we store the data into db and for view we are using unescape js function. Till this everything fine. Now we are also sending email and storing in excel with the data. So we cant use js here. – Manoj May 12 '11 at 13:20
  • We tried your suggestion above, but in jsp, it can't differentiate the two quotes. So this function String.replace("“", "\"") is not useful. From server side we cant use this, becauz we already escaped the character. so some bla bla text will appear. – Manoj May 12 '11 at 13:21