Java Unicode Confusion

前端 未结 5 1049
无人及你
无人及你 2020-12-18 05:03

HEy all, I have only just started attempting to learn Java and have run into something that is really confusing!

I was typing out an example from the book I am using

5条回答
  •  时光取名叫无心
    2020-12-18 05:38

    The \u00ab character is not the 1/2 character; see this definitive code page from the Unicode.org website.

    What you are seeing is (I think) a consequence of using the System.out PrintStream on a platform where the default character encoding is not UTF-8 or Latin-1. Maybe it is some Windows character set as suggested by @axtavt's answer? (It also has a plausible explanation of why \u00ab is displayed as 1/2 ... and not some "splat" character.)

    (In Unicode and Latin-1, \00BD is the codepoint for the 1/2 character.)

提交回复
热议问题