My language is Portuguese, so i need to write a method doSomething()
, which in Portuguese is faƧaAlgo()
.
Java allows me to use special characters in the code, but is it safe? What are the disadvantages of doing so? Or can i use it without worrying?
It's valid Java, but you're slightly more likely to run into problems when:
Pretty much everything handles ASCII with no problems, and most encodings are either compatible with ASCII or editors will guess correctly if you use ASCII. However, when you start using characters outside ASCII, you need to make sure everything uses the same encoding, or you'll end up with different tools thinking your code has different characters in.
If you do use non-ASCII characters, I'd recommend using UTF-8 as the encoding - it's supported basically everywhere these days. Make sure whatever IDE you're using creates new files using UTF-8 by default, and expects existing files to be in UTF-8. Then if you compile from the command line, use the -encoding
command line argument to specify the encoding.
See more on this question at Stackoverflow