Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the Chinese problem of Java

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "how to solve the Java Chinese problem". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn this article "how to solve the Java Chinese problem".

I'll tell you how tomcat implements JSP.

Preliminary knowledge:

1. Bytes and unicode

The Java kernel is unicode, even class files, but many media, including file / stream, are saved.

It uses byte streaming. So Java has to convert these byte streams through lines. Char is unicode and byte is byte.

The byte/char interchange function in Java is found in the middle of the sun.io package. Where the ByteToCharConverter class is the medium scheduling

Can be used to tell you that you use Convertor. Two of the commonly used static functions are

Public static ByteToCharConverter getDefault ()

Public static ByteToCharConverter getConverter (String encoding)

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

8859_1

Let's take a simple example:

The GB code of "you" is 0xC4E3, and unicode is 0x4F60.

You use:

-encoding= "gb2312"

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

-- convertor=ByteToCharConverter.getConverter (encoding)

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

-- for (int itemositani)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report