Input_ASCII.java 899 B

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