2

Norwegian alphabet have characters such as Ø, Å, Æ..

    char character = 'Ø';
    int ascii = (int) character;
    System.out.println(ascii);

And it returns = 65533

    char character = 'Æ';
    int ascii = (int) character;
    System.out.println(ascii);

And it also returns = 65533

How does it possible to distinguish these characters when they are entered from keyboard?

vlcod
  • 229
  • 2
  • 3
  • 13

2 Answers2

0

An easy approach to your problem could be to use the .replaceAll(String regex, String replacement) method available in the string class. This would allow you to replace all instances which match the given regular expression. Thus, the code below:

    String input = "Løre lære i kjøpe";
    String result = input.replaceAll("ø", "oo");
    result = result.replaceAll("æ", "ae");
    System.out.println(result);

Would yield:

Loore laere i kjoope

Thus, you could have a method which processes the text through a series of replace calls. You could add some intelligence to it and allow it to also replace capitalized words with their English equivalent.

If you have a lot of them, you could create a configuration file which your application then loads in a Map like structure. You could then iterate over the map and use it to replace chunks of text from your source string.

npinti
  • 51,780
  • 5
  • 72
  • 96
0

Your settings are wrong. The characters are actually 216 and 198. 65533 is the Unicode Replacement Character which is used when an unsupported character is encountered (usually due to wrong encoding). If it works in Eclipse, then check your IDEA settings for any encoding options.

Recommended reading: http://joelonsoftware.com/articles/Unicode.html

Kayaman
  • 72,141
  • 5
  • 83
  • 121