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

后端 未结 5 422
小鲜肉
小鲜肉 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条回答
  •  -上瘾入骨i
    2021-01-14 21:07

    Not sure where the problem is exactly, but it's worth noting that

    ¿ ( 0xc2,0xbf)

    is the result of encoding with UTF-8

    0xbf,

    which is the Unicode codepoint for ¿

    So, it looks like in the linux case, the output is not being displayed as utf-8, but as a single-byte string

提交回复
热议问题