01: /*
02: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/lib/TKIso88591Converter.java,v 1.7 2002/01/21 09:50:17 mischa Exp $
03: *
04: */
05: package com.teamkonzept.lib;
06:
07: /**
08: * Konvertierungsklasse fuer ISO-8859-1
09: * Nutzen ??? gleiche wie AnsiConverter ?
10: * @author $Author: mischa $
11: * @version $Revision: 1.7 $
12: */
13: public class TKIso88591Converter extends TKConverter {
14: public String getName() {
15: return "ISO-8859_1";
16: }
17:
18: public int getMaxBytesPerChar() {
19: return 1;
20: }
21:
22: public int minCharSize(int byteCount) {
23: return byteCount;
24: }
25:
26: public int charsToBytes(char src[], byte dst[], int srcBegin,
27: int length, int dstBegin) {
28: int lastPos = srcBegin + length;
29: int firstPos = dstBegin;
30: for (int i = srcBegin; i < lastPos; i++) {
31: char c = src[i];
32: if (c <= '\u00FF') {
33: dst[dstBegin++] = (byte) c;
34: }
35: }
36: return dstBegin - firstPos;
37: }
38:
39: public int bytesToChars(byte src[], char dst[], int srcBegin,
40: int length, int dstBegin) {
41: int lastPos = srcBegin + length;
42: //int firstPos = dstBegin;
43: for (int i = srcBegin; i < lastPos; i++) {
44: dst[dstBegin++] = (char) src[i];
45: }
46: return length;
47: }
48:
49: public String bytesToString(byte[] code) {
50: return new String(code, 0);
51: }
52:
53: public byte[] stringToBytes(String src) {
54: int len = src.length();
55: byte[] temp = new byte[len];
56: src.getBytes(0, len, temp, 0);
57: return temp;
58: }
59: }
|