encoding - java convert utf-8 2 byte char to 1 byte char -


There are many similar questions, but no one does help me.

utf-8 can be 1 byte or 2,3,4

ISO-8859-15 is always the entire bytes.

But I need a byte character like 1 page code "Page 863" (IBM 863).

For example, "é" code is 233 and UTF 8 is 2 bytes long, how can I convert it to IBMMb3 (1 byte)?

Is it possible to run JVM -Dfile.encoding = UTF-8?

Definitely a conversion would mean that some letters might be lost because IBM863 is small. But I need special characters in languages ​​like French, è, etc.

Editing 1:

  string text = "text with AA"; Socket socket = getPrinterSocket (printer); Buffedriver bevote = getPrinterWriter (printer, socket); ... bwOut.write ("PRTXT \" "+ text +" \ n "); ... if (socket! = Null) {bwOut.close (); socket.clos ();} and {bwOut.flush ();}  

A label printer with fingerprint 8.2 is going.

Edit 2:

  Private BufferedWriter getPrinterWriter ( PrinterLocal printers, socket sockets) throws IOException {back to new BufferedWriter (new output stream water (socket.getOutputStream ())}  

First of all: "1 byte four" or indeed, there is no such thing as "n byte four".

In Java, enter a char A UTA F-16 is a code unit, (Unicode), depending on the code point, one or two char s are required to represent a code point.

You can use:

  • To convert a unicode code point to a char array representing this code point;
  • four [] to byte [] conversion to one;
  • To convert a byte [] to four [] .

You get two from a charset to .new {encoder, decoder} () .

It is important to know exactly what your input is: this is a code point, is it an encoded byte array? You have to customize your code depending on this.

The final note: defines the default charset to use the file.encoding setting when you do not specify a charset for use, for example, a < Code> FileReader in the constructor; You must not specify a charset to begin!


Comments