Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libjava / gnu / gcj / convert / Output_ASCII.java
blob9f336452501b2977ce0a5ee8d21c6b2a58c704ef
1 /* Copyright (C) 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 ASCII
13 * Unrecognized characters are printed as `?'.
14 * @date October 2000
17 public class Output_ASCII extends UnicodeToBytes
19 public String getName() { return "ASCII"; }
21 /**
22 * @return number of chars converted. */
23 public int write (char[] inbuffer, int inpos, int inlength)
25 int count = this.count;
26 byte[] buf = this.buf;
27 int avail = buf.length - count;
28 if (inlength > avail)
29 inlength = avail;
30 for (int i = inlength; --i >= 0; )
32 char c = inbuffer[inpos++];
33 buf[count++] = (byte) ((c > 0x7f) ? '?' : c);
35 this.count = count;
36 return inlength;
39 public int write (String str, int inpos, int inlength, char[] work)
41 int count = this.count;
42 byte[] buf = this.buf;
43 int avail = buf.length - count;
44 if (inlength > avail)
45 inlength = avail;
46 for (int i = inlength; --i >= 0; )
48 char c = str.charAt(inpos++);
49 buf[count++] = (byte) ((c > 0x7f) ? '?' : c);
51 this.count = count;
52 return inlength;