Chinese processing of Java language

xiaoxiao2021-03-06  69

Java's basic Char type is defined into a 16-bit, which is only one unmanned type in Java. The main reason for the use of 16-bit episodes is to allow Java to support any Unicode characters, and thus make Java adapted to describe or display any language that is supported by Unicode, the portability is better. However, it is possible to support a string of a language to display, and it is necessary to print a string of a language that is often two different issues. The main environmental environment of the issuing group of Oak (Java's first generation) is UNIX system and some of the Unix system, which is ISO LATIN-1. Accordingly, this development group has UNIX genetic, which also leads to the Java I / O system to a large extent, in the UNIX stream concept, and in the UNIX system, each I / O device They are all represented by a string of 8 bits. This method of taking the UNIX in the I / O system, so that Java language has 16 Java characters, but only 8-bit input device, this is not enough to bring Java. Therefore, in any Java string, it is read or written in 8 bits. It has a short program code, called "Hack", to make 8-bit character mapping into 16-bit Unicode, or The 16-bit Unicode is smashed into 8-bit characters.

example:

The following program code: Speaking names, use the InputStringReader class, from the original Byte data to the established character set

Import java.io. *;

Public Class Rfnew

{

Public static void main (string args [])

{

FileInputstream Fis;

InputStreamReader ISR;

CHAR CH;

Try

{

FIS = New FileInputStream ("gq.txt");

ISR = New InputStreamReader (FIS);

While (True)

{

CH = (char) isr.read ();

System.out.print (CH);

System.out.flush ();

IF (CH == '/ n') Break;

}

fis.close ();

}

Catch (Exception E) {}

System.exit (0);

}

}

InputStringReader Class Description:

转载请注明原文地址:https://www.9cbs.com/read-87628.html

New Post(0)