gcc/libjava/gnu/gcj/convert/Input_ASCII.java
Tom Tromey f92351d76e encodings.pl: Added `ASCII' alias.
* scripts/encodings.pl: Added `ASCII' alias.
	* Makefile.in: Rebuilt.
	* Makefile.am (convert_source_files): Added new files.
	* gnu/gcj/convert/Input_ASCII.java: New file.
	* gnu/gcj/convert/Output_ASCII.java: New file.
	* gnu/gcj/convert/Output_8859_1.java (write): Use `?' to represent
	out-of-range characters.
	* gnu/gcj/convert/natIconv.cc (iconv_init): New method.
	(read): Swap bytes if required.  Treat `count' as character count,
	not byte count.
	(write): Likewise.  Also, handle case where iconv fails on a given
	character.
	(init): Put encoding into exception.
	* gnu/gcj/convert/IOConverter.java (iconv_byte_swap): New global.
	(static): Call iconv_init.  Rebuilt alias list.
	(iconv_init): New private method.

From-SVN: r37190
2000-11-01 17:00:02 +00:00

38 lines
899 B
Java

/* Copyright (C) 2000 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package gnu.gcj.convert;
/**
* Convert ASCII text to Unicode.
* @date October 2000
*/
public class Input_ASCII extends BytesToUnicode
{
public String getName() { return "ASCII"; }
public int read (char[] outbuffer, int outpos, int count)
{
int origpos = outpos;
// Make sure fields of this are in registers.
int inpos = this.inpos;
byte[] inbuffer = this.inbuffer;
int inavail = this.inlength - inpos;
int outavail = count;
if (outavail > inavail)
outavail = inavail;
while (--outavail >= 0)
{
outbuffer[outpos++] = (char) (inbuffer[inpos++] & 0x7f);
}
this.inpos = inpos;
return outpos - origpos;
}
}