From 4ae7d3a8b0dd16f89cf76f91c8052308987f45e2 Mon Sep 17 00:00:00 2001 From: daney Date: Thu, 28 Oct 2004 15:22:44 +0000 Subject: 2004-10-28 David Daney * gnu/gcj/convert/Output_UnicodeLittleUnmarked.java: New file. * Makefile.am: Build it. * Makefile.in: Regenerate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@89763 138bc75d-0d04-0410-961f-82ee72b054a4 --- .../gcj/convert/Output_UnicodeLittleUnmarked.java | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 libjava/gnu/gcj/convert/Output_UnicodeLittleUnmarked.java (limited to 'libjava/gnu') diff --git a/libjava/gnu/gcj/convert/Output_UnicodeLittleUnmarked.java b/libjava/gnu/gcj/convert/Output_UnicodeLittleUnmarked.java new file mode 100644 index 00000000000..a6b6336a216 --- /dev/null +++ b/libjava/gnu/gcj/convert/Output_UnicodeLittleUnmarked.java @@ -0,0 +1,41 @@ +/* Copyright (C) 2004 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 to Unicode Little Endian, no marker + */ +public class Output_UnicodeLittleUnmarked extends UnicodeToBytes +{ + public String getName() { return "UnicodeLittleUnmarked"; } + + /** Convert chars to bytes. + * Converted bytes are written to buf, starting at count. + * @param inbuffer source of characters to convert + * @param inpos index of initial character in inbuffer to convert + * @param inlength number of characters to convert + * @return number of chars converted + * Also, this.count is increment by the number of bytes converted. + */ + public int write (char[] inbuffer, int inpos, int inlength) + { + int avail = buf.length - count; + if (inlength * 2 > avail) + inlength = avail / 2; + for (int i = inlength; i > 0; i--) + { + char c = inbuffer[inpos++]; + buf[count] = (byte)c; + buf[count+1] = (byte)(c >> 8); + count += 2; + } + return inlength; + } +} + -- cgit v1.2.3