How to show pound sign (Β£) in Java Swing?

I am currently adding the pound sign (& lb;) to the Java source and compiling the resulting Swing component as a square symbol (unsupported symbol).

I suspect this is an encoding issue, the Java source file is encoded as cp1252 (default is Eclipse by default). What is the correct way to resolve this?

+4
source share
4 answers

Use the notation \ u00A3. Other examples here are for unicodes. Unicode code points for other characters.

+11
source

I believe that you can change the encoding of the source code from Eclipse (or from any decent editor). Install it in UTF-8. Then everything should behave smoothly because Java strings are Unicode.

I would highly recommend using the correct encoding in the source instead of this \ uXXX entry. The reason is how you exit the code, which means, for example, the value \ u00A3? It is much clearer just to put the correct character there.

+2
source

maybe messing around with java.util.Currency getSymbol () may give some results

0
source
Locale locale = Locale.UK; Currency curr = Currency.getInstance(locale); System.out.println("Symbol: " + curr.getSymbol()); 

In some currencies it works.

0
source

Source: https://habr.com/ru/post/1286343/


All Articles