home *** CD-ROM | disk | FTP | other *** search
- package icontrols.RichText;
-
- import com.ms.dll.DllLib;
-
- class UnicodeBuffer extends CharBuffer {
- char[] buffer;
- int offset;
-
- int allocCoTaskMem() {
- int result = DllLib.allocCoTaskMem(this.buffer.length * 2);
- DllLib.copy(this.buffer, 0, result, this.buffer.length);
- return result;
- }
-
- void putCoTaskMem(int ptr) {
- DllLib.copy(ptr, this.buffer, 0, this.buffer.length);
- this.offset = 0;
- }
-
- UnicodeBuffer(int size) {
- this.buffer = new char[size];
- }
-
- public String getString() {
- int i;
- for(i = this.offset; i < this.buffer.length && this.buffer[i] != 0; ++i) {
- }
-
- String result = new String(this.buffer, this.offset, i - this.offset);
- if (i < this.buffer.length) {
- ++i;
- }
-
- this.offset = i;
- return result;
- }
-
- public void putString(String s) {
- int count = Math.min(s.length(), this.buffer.length - this.offset);
- s.getChars(0, count, this.buffer, this.offset);
- this.offset += count;
- if (this.offset < this.buffer.length) {
- this.buffer[this.offset++] = 0;
- }
-
- }
- }
-