• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using smart quotes with JTextComponent

 
Ritika Saxena
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to use smart quotes i.e curly single and double quotes in place of straight quotes(as given in keyboards) with TextComponents.
Can anyone give me an idea for this.
 
Campbell Ritchie
Marshal
Posts: 52590
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

What do you mean by "smart quotes?" Do you mean that whenever you put in a quote mark after whitespace it comes out as "open" and "close" after not-whitespace?
Or are you going to put them in by hand.

Both are possible. If you iterate through the String (a StringBuilder object would be better however) and change your " to "open" after whitespace, then change all remaining " to "close," that would work.

You can do it by hand using an escape sequence.

You know where to find lists of Unicode characters? Here. Try "punctuation and symbols."
 
Ritika Saxena
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Actualy I am working with textarea. When I enter quotes(' or ") in a textarea, I want them to come as:
Open double: �adfsgd
Close double: sgdaks�
Open single: �hggh
Close single: hjkhg�

These quotes should be curly (as with Times New Roman font in MSword)

Thanks
 
Campbell Ritchie
Marshal
Posts: 52590
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will work, using either of the techniques I mentioned earlier. You will have to go through the Unicode sheets to find the right numbers.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!