Source for gnu.gcj.convert.Input_ASCII

   1: /* Copyright (C) 2000  Free Software Foundation
   2: 
   3:    This file is part of libgcj.
   4: 
   5: This software is copyrighted work licensed under the terms of the
   6: Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
   7: details.  */
   8: 
   9: package gnu.gcj.convert;
  10: 
  11: /**
  12:  * Convert ASCII text to Unicode.
  13:  * @date October 2000
  14:  */
  15: 
  16: public class Input_ASCII extends BytesToUnicode
  17: {
  18:   public String getName() { return "ASCII"; }
  19: 
  20:   public int read (char[] outbuffer, int outpos, int count)
  21:   {
  22:     int origpos = outpos;
  23:     // Make sure fields of this are in registers.
  24:     int inpos = this.inpos;
  25:     byte[] inbuffer = this.inbuffer;
  26:     int inavail = this.inlength - inpos;
  27:     int outavail = count;
  28:     if (outavail > inavail)
  29:       outavail = inavail;
  30:     while (--outavail >= 0)
  31:       {
  32:     outbuffer[outpos++] = (char) (inbuffer[inpos++] & 0x7f);
  33:       }
  34:     this.inpos = inpos;
  35:     return outpos - origpos;
  36:   }
  37: }