/**
 * 字符串转二进制
 * */
import { replaceAll } from '@/webPublic/one_stop_public/Base16/utils';

export function strToBinary(str) {
  let result = [];
  let list = str.split('');
  for (let i = 0; i < list.length; i++) {
    if (i !== 0) {
      result.push('_');
    }
    let item = list[i];
    let binaryStr = item.charCodeAt()
      .toString(2);
    result.push(binaryStr);
  }
  let resultStr = result.join('');
  resultStr = replaceAll(resultStr, '0', '-');
  resultStr = replaceAll(resultStr, '1', '.');
  return resultStr;
}
