Previous topicNext topic
 XXXX Help
Help > Modules > utility class >

 Byte array and string array are inter-transfered. It is frequently used to print log.

 /**
  * BCD code is transfered to ASCII code,eg: hex("\x21\x31\x24") 转成 "213124"
  *
  * @param bcdNum
  *            BCD code

  * @param offset
  *             which code is the transfermation  started from 
  * @param numlen
  *           length the BCD code

  * @return
  */
String bcdToString (byte[] bcdNum, int offset, int numlen) ;

 /**
  * hexadecimal array is transfered to string(capital letter)
  *
  * @param b
  * @return
  */
String hex2DebugHexString (byte[] b, int len) ;

  /**
     * int value is transfered to byte[] with 4bytes
     * @param value
     *            int value to be transfered
     * @return byte[]
     */ 
byte[] intToBytes ( int value ) ;
 

  /**
     * int array is transfered to byte[] with 4bytes
     */ 
byte[] intToBytes2 (int value) ;

 
  /**
     * int value in byte[] array
     * 
     * @param src t
     *            byte array
     * @param offset
     *             start from the offset
     * @return int value 
     */ 
int bytesToInt (byte[] src, int offset);
 
  /**
     * int value in  byte[] array
     */
int bytesToInt2 (byte[] src, int offset) ;
 
 /**
  * is the length of the two arrays the same
  * @return
  */
boolean memcmp (byte[] src,int srcposition,byte[] des,int desposition,int len);
  
void memset (byte[] src, byte des,int length);


void memcpy (byte[] des,byte[] src,int length);

 
 /**
  * Is certain data  in the array
  * @param src
  * @param des
  * @return
  */
boolean ifContain (byte[] src,byte des);


char ConvertHexChar (char ch) ;

 // byte value is transfered to INT value
int byte2int (byte val) ;

byte[] StrToBCD (String str) ;

byte[] StrToBCD (String str, int numlen);

byte[] stringToBcd (String src, int numlen) ;