import { replaceAll } from '../Base16/utils';

/**
 * 二进制字符串转JSON字符串
 * */
export function binaryToStr(binaryStr = '') {
  let res = '';
  if (binaryStr) {
    binaryStr = replaceAll(binaryStr, '\\.', '1');
    binaryStr = replaceAll(binaryStr, '-', '0');
    let strListArr = binaryStr.split('_');
    for (let i = 0; i < strListArr.length; i++) {
      let item = strListArr[i];
      res += String.fromCharCode(parseInt(item, 2));
    }
  }
  return res;
}
