1 5 package com.teamkonzept.lib; 6 7 13 public class TKIso88591Converter extends TKConverter { 14 public String 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 for( int i = srcBegin; i < lastPos; i++ ) { 47 dst[dstBegin++] = (char) src[i]; 48 } 49 return length; 50 } 51 52 public String bytesToString( byte[] code ) 53 { 54 return new String ( code, 0 ); 55 } 56 57 public byte[] stringToBytes( String 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 |