1

My test program is:

public class Test { public static void main(String[] args) { char ch = 65270; StringBuilder sb = new StringBuilder(); sb.append(ch); sb.append(" -> "); sb.append(Integer.valueOf(ch)); System.out.println(sb.toString()); } } 

Result is : 65270 <- ﻶ

I can not understand why ?

I expire result is : ? -> 65270

Actual result in terminal (use command "javac Test.java" and "java Test") : ? -> 65270

But in Eclipse console : 65270 <- ?

It looks like an Eclipse problem ?

6
  • 1
    I can not understand why it should do something different. What behavior would you expect? Commented Nov 23, 2014 at 6:48
  • I get ? -> 65270 when running this code Commented Nov 23, 2014 at 6:49
  • @Eran that's because u probably have Hebrew keyboard Commented Nov 23, 2014 at 6:50
  • Yes, but what do you think you should get? Commented Nov 23, 2014 at 6:50
  • Try using UTF-8 encoding, what environment do you use? Commented Nov 23, 2014 at 6:53

1 Answer 1

1

The reason for your result is that the character 65270 is an Arabic ligature. Arabic is a script that is written from right to left. The Eclipse console therefore changes the direction from left-to-right to right-to-left. If you try a character from a script that is not a right-to-left script, results will be as expected. Try 0x5678 which is the old Chinese symbol for ton (weight), for example.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.