Why is ¿ displayed different in Windows vs Linux even when using UTF-8?

后端 未结 5 478
小鲜肉
小鲜肉 2021-01-14 20:49

Why is the following displayed different in Linux vs Windows?

System.out.println(new String(\"¿\".getBytes(\"UTF-8\"), \"UTF-8\"));

in Wind

5条回答
  •  醉酒成梦
    2021-01-14 21:12

    It's hard to know exactly which bytes your source code contains, or the string which getBytes() is being called on, due to your editor and compiler encodings.

    Can you produce a short but complete program containing only ASCII (and the relevant \uxxxx escaping in the string) which still shows the problem?

    I suspect the problem may well be with the console output on either Windows or Linux, but it would be good to get a reproducible program first.

提交回复
热议问题