質問

I would like to concatenate the Rupee Symbol Unicode '\u20B9' to a String in java, but I get the following Error, I am using jre7 it has been told in java docs that java7 supports unicode6.0 where this rupee Symbol is added in that version., I have attached my code ant its output below.

public class no {

public static void main(String[] args) {

      String rupee = "\u20B9";
      JOptionPane.showMessageDialog(null,"Total Amount"+rupee);

    }
 }

enter image description here

役に立ちましたか?

解決

This is not a problem of a string concatenation. It's a problem of the display font. It just doesn't support the character. If I try it on my machine where the standard display fonts have full unicode support, this is the result:

Result with unicode character support

You should try to use a font that has the support, rather than the standard font.

他のヒント

You need a font capable of displaying a glyph for that codepoint. Since the Rupee symbol is relatively new that might be hard. There is no problem with your code here, since you see a square which just means that the font doesn't have a glyph for that character and no suitable other font could be found (assuming that Java does font substitution, I'm not terribly sure of that).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top