KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > teamkonzept > lib > TKIso88591Converter


1 /*
2  * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/lib/TKIso88591Converter.java,v 1.7 2002/01/21 09:50:17 mischa Exp $
3  *
4  */

5 package com.teamkonzept.lib;
6
7 /**
8  * Konvertierungsklasse fuer ISO-8859-1
9  * Nutzen ??? gleiche wie AnsiConverter ?
10  * @author $Author: mischa $
11  * @version $Revision: 1.7 $
12 */

13 public class TKIso88591Converter extends TKConverter {
14     public String JavaDoc getName()
15     {
16         return "ISO-8859_1";
17     }
18     
19     public int getMaxBytesPerChar()
20     {
21         return 1;
22     }
23     
24     public int minCharSize(int byteCount)
25     {
26         return byteCount;
27     }
28     
29     public int charsToBytes(char src[], byte dst[], int srcBegin, int length, int dstBegin)
30     {
31         int lastPos = srcBegin+length;
32         int firstPos = dstBegin;
33         for( int i=srcBegin; i<lastPos; i++ ) {
34             char c = src[i];
35             if( c <= '\u00FF' ) {
36                 dst[ dstBegin++ ] = (byte) c;
37             }
38         }
39         return dstBegin - firstPos;
40     }
41     
42     public int bytesToChars(byte src[], char dst[], int srcBegin, int length, int dstBegin)
43     {
44         int lastPos = srcBegin+length;
45         //int firstPos = dstBegin;
46
for( int i = srcBegin; i < lastPos; i++ ) {
47             dst[dstBegin++] = (char) src[i];
48         }
49         return length;
50     }
51
52     public String JavaDoc bytesToString( byte[] code )
53     {
54         return new String JavaDoc( code, 0 );
55     }
56
57     public byte[] stringToBytes( String JavaDoc src )
58     {
59         int len = src.length();
60         byte[] temp = new byte[ len ];
61         src.getBytes( 0, len, temp, 0 );
62         return temp;
63     }
64 }
65
66
67
Popular Tags