Coding garbled problem in Java

Source: Internet
Author: User

1. In Eclipse's run configurations, you can configure the console's encoding

Eclipse uses the MVN Clean Package command to execute.

When set to MS932, the following code, ① is the logger output of Logback, ② is the output of System.out, and ③ is a junit assertion.

   Public void testApp () {    asserttrue (true);    Logger.warn ("Logger.warn testapptest:モック machine can が しています." ");    System.out.print ("System.out.print testapptest:モック machine can が しています." ");     = "str";    Assert.assertnull ("nullではありません. ", str);  }

The results obtained, ①, ②, ③ are OK:

When set to UTF-8, only the ③ is OK when the result is obtained:

Using JUnit-related commands in eclipse, the resulting results are OK. No garbled. Seems to be unrelated to the encoding configuration.

2.Git Bash can set its encoding Character set

Git Bash executes the MVN clean package.

When encoded as Sjis, ①, ②, ③ are OK

When encoded as UTF-8, ①, ②, ③ are all Ng

Todo

Coding garbled problem in Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.