Number of characters occupied by strings in different character encodings in Java

Source: Internet
Author: User

The number of bytes occupied by strings in Java is closely related to character encoding.

Java coding can actually involve these aspects: ide encoding, operating system default encoding, and Java character encoding.

For example, we use eclipse to compile JavaProgramYou can set the Java program encoding in the project attribute. If this parameter is not set, the program encoding is the operating system encoding by default.CodeFile encoding; or when we use Vim to write a Java program, you can set the system environment variable Lang, such as zh_CN.UTF-8, zh_cn.gb18030, etc. At this time, the code file encoding is the Lang specified encoding. This is the IDE encoding, IDE encoding is very important, for example, a Java code file is UTF-8 encoding, and your ide is gb18030 encoding, then the display will appear garbled.

Http://blog.csdn.net/xiaoyu714543065/article/details/7380191

 

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.