Advertisement

将Java字符串转换为BCD码

阅读量:

字符串转换为BCD编码

复制代码
  public static byte[] str2Bcd(String asc) {

    
     int len = asc.length();
    
     int mod = len % 2;
    
  
    
     if (mod != 0) {
    
         asc = "0" + asc;
    
         len = asc.length();
    
     }
    
  
    
     byte abt[] = new byte[len];
    
     if (len >= 2) {
    
         len = len / 2;
    
     }
    
  
    
     byte bbt[] = new byte[len];
    
     abt = asc.getBytes();
    
     int j, k;
    
  
    
     for (int p = 0; p < asc.length() / 2; p++) {
    
         if ((abt[2 * p] >= '0') && (abt[2 * p] <= '9')) {
    
             j = abt

全部评论 (0)

还没有任何评论哟~