2013-11-04 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / libjava / gnu / gcj / convert / Output_8859_1.java
blob7ae6a615f2306306dda2d0ad7d3e5ac7a9cf2739
1 /* Copyright (C) 1999, 2000 Free Software Foundation
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
7 details. */
9 package gnu.gcj.convert;
11 /**
12 * Convert Unicode ISO-Latin-1 (8851-1) text.
13 * Unrecognized characters are printed as `?'.
14 * @author Per Bothner <bothner@cygnus.com>
15 * @date March 1999.
18 public class Output_8859_1 extends UnicodeToBytes
20 public String getName() { return "8859_1"; }
22 /**
23 * @return number of chars converted. */
24 public int write (char[] inbuffer, int inpos, int inlength)
26 int count = this.count;
27 byte[] buf = this.buf;
28 int avail = buf.length - count;
29 if (inlength > avail)
30 inlength = avail;
31 for (int i = inlength; --i >= 0; )
33 char c = inbuffer[inpos++];
34 buf[count++] = (byte) ((c > 0xff) ? '?' : c);
36 this.count = count;
37 return inlength;
40 public int write (String str, int inpos, int inlength, char[] work)
42 int count = this.count;
43 byte[] buf = this.buf;
44 int avail = buf.length - count;
45 if (inlength > avail)
46 inlength = avail;
47 for (int i = inlength; --i >= 0; )
49 char c = str.charAt(inpos++);
50 buf[count++] = (byte) ((c > 0xff) ? '?' : c);
52 this.count = count;
53 return inlength;