1 /* Copyright (C) 1999 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
9 package gnu
.gcj
.convert
;
12 * Convert Unicode to Ascii with \ u XXXX-escapes.
13 * @author Per Bothner <bothner@cygnus.com>
17 public class Output_JavaSrc
extends UnicodeToBytes
19 public String
getName() { return "JavaSrc"; }
21 // Number of bytes remaining before pending_char has been written.
25 public int write (char[] inbuffer
, int inpos
, int inlength
)
27 int start_pos
= inpos
;
28 int avail
= buf
.length
- count
;
36 if (pending_char
== '\\')
38 buf
[count
++] = (byte) '\\';
43 /* ... else fall through ... */
48 int digit
= ((int) pending_char
>> (todo
* 4)) & 0xF;
49 buf
[count
++] = (byte) Character
.forDigit(digit
, 16);
53 buf
[count
++] = (byte) 'u';
62 char ch
= inbuffer
[inpos
++];
66 buf
[count
++] = (byte) '\\';
73 buf
[count
++] = (byte) ch
;
78 buf
[count
++] = (byte) '\\';
84 return inpos
- start_pos
;