Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of Chinese problems in Java

Shulou Source: shulou.com Published: 2022-06-02 05:21:38 09月17日 Update

This article will explain in detail the sample analysis of Java Chinese problems for everyone. Xiaobian thinks it is quite practical, so share it with you for reference. I hope you can gain something after reading this article.

Let me tell you how tomcat implements JSP and you will understand.

Preparatory knowledge:

1. Byte and unicode

Java kernel is unicode, even class files are, but a lot of media, including file/stream storage

is using byte streams. So Java has to translate these byte streams into lines. char is unicode and byte is byte.

Java byte/char conversion function in the middle of the package sun.io. where ByteToCharConverter is scheduled

It can be used to tell you which converter you use. Two very common static functions are

public static ByteToCharConverter getDefault() ;

public static ByteToCharConverter getConverter(String encoding);

If you do not specify converter, the system automatically uses the current Encoding, GBK on GB,EN on EN

8859_1

Let's take a simple example:

GB code for "you" is 0xC 4E3,unicode is 0x4F 60

You use:

--encoding="gb2312";

--byte b[]={(byte)'u00c4',(byte)'u00E3'};

--convertor=ByteToCharConverter.getConverter(encoding);

--char [] c=converter.convertAll(b);

--for(int i=0;i

Tags: Platform compilation file Chinese English Chinese platform coding problems parameters variables only interpretation two examples that is UTF-8 run binary hello function Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Xiaomi Shulou Tech Info MariaDB MySQL