Diamond garbled characters appear in Java code?
# Diamond garbled characters appear in Java code?
Diamond-shaped garbled characters appear in Java code. Generally, it is due to character set issues. For example, the Java file is GBK encoded, but when the editor opens the Java file with UTF-8 encoding, this kind of garbled code is displayed. Solve it Method: Change the editor's encoding to the same encoding as the Java file.
Encoding
Encoding is the process of converting information from one form or format to another, also The code called a computer programming language is simply called coding. Use a predetermined method to encode characters, numbers or other objects into numbers, or convert information and data into prescribed electrical pulse signals. Coding is widely used in electronic computers, televisions, remote controls and communications. Encoding is the process of converting information from one form or format to another. Decoding is the reverse process of encoding.
Among the GB encoding standards, the more commonly used ones are GB2312 and GBK. GB2312 is a subset of GBK. The GB2312 encoding range is 0xA1A1 - 0xFEFE. If it is pure GB2312 encoding, it is very simple to process. But there are some small tips when dealing with the GBK character set. Let’s talk about the GBK encoding standard first:
GBK uses double-byte representation. The overall encoding range is 8140-FEFE, and the first byte is between 81-FE. , the last byte is between 40-FE, and a line of xx7F is eliminated. There are a total of 23,940 code points, and a total of 21,886 Chinese characters and graphic symbols are included, including 21,003 Chinese characters (including radicals and components) and 883 graphic symbols.
Encoding classification
1. Chinese character area. Including:
a. GB 2312 Chinese character area. That is GBK/2: B0A1-F7FE. Contains 6763 GB 2312 Chinese characters, arranged in original order.
b. GB 13000.1 Expand the Chinese character area. Includes:
(1) GBK/3: 8140-A0FE. Contains 6080 CJK Chinese characters in GB 13000.1.
(2) GBK/4: AA40-FEA0. Contains 8160 CJK Chinese characters and supplemented Chinese characters.
CJK Chinese characters are at the front, arranged according to UCS code size; supplementary Chinese characters (including radicals and components) are at the end, arranged according to the page number/character position of the "Kangxi Dictionary".
2. Graphic symbol area. Including:
a. GB 2312 non-Chinese character symbol area. That is GBK/1: A1A1-A9FE. In addition to the symbols of GB 2312,
also has 10 lowercase Roman numerals and symbols supplemented by GB 12345. There are 717 symbols in total.
b. GB 13000.1 Expand the non-Chinese character area. That is GBK/5: A840-A9A0. BIG-5 Non-Chinese characters, structural symbols and "○" are arranged in this area. There are 166 symbols in total.
3. User-defined area: divided into three areas (1)(2)(3).
(1) AAA1-AFFE, 564 code points.
(2) F8A1-FEFE, 658 code points.
(3) A140-A7A0, 672 code points.
Although area (3) is open to users, its use is restricted because the possibility of adding new characters to this area in the future cannot be ruled out.
Here are a few tips:
1. In php, the character encoding is based on the encoding sent, so the encoding input by the user is used and will not change automatically. , but in asp, the default encoding is unicode, so we can easily get the encoding comparison table of gbk->unicode, so that we can easily implement gbk to utf-8 even without any basic library. Converted;
2. Since the lowest value of GBK’s high bit is 0x40, which is 64, therefore, sometimes when organizing some strings involving Chinese, it is best to use the ascii code before 64 to separate characters, so There will be no garbled characters when replacing or dividing under any circumstances. The more commonly used characters are ",", ";", ":", " ", " ", " ". These characters will never cause confusion in gb encoding
Recommended tutorial: "Java Tutorial"
The above is the detailed content of Diamond garbled characters appear in Java code?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Guide to Smith Number in Java. Here we discuss the Definition, How to check smith number in Java? example with code implementation.

In this article, we have kept the most asked Java Spring Interview Questions with their detailed answers. So that you can crack the interview.

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

Guide to TimeStamp to Date in Java. Here we also discuss the introduction and how to convert timestamp to date in java along with examples.

Capsules are three-dimensional geometric figures, composed of a cylinder and a hemisphere at both ends. The volume of the capsule can be calculated by adding the volume of the cylinder and the volume of the hemisphere at both ends. This tutorial will discuss how to calculate the volume of a given capsule in Java using different methods. Capsule volume formula The formula for capsule volume is as follows: Capsule volume = Cylindrical volume Volume Two hemisphere volume in, r: The radius of the hemisphere. h: The height of the cylinder (excluding the hemisphere). Example 1 enter Radius = 5 units Height = 10 units Output Volume = 1570.8 cubic units explain Calculate volume using formula: Volume = π × r2 × h (4

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

Java is a popular programming language that can be learned by both beginners and experienced developers. This tutorial starts with basic concepts and progresses through advanced topics. After installing the Java Development Kit, you can practice programming by creating a simple "Hello, World!" program. After you understand the code, use the command prompt to compile and run the program, and "Hello, World!" will be output on the console. Learning Java starts your programming journey, and as your mastery deepens, you can create more complex applications.
