function codesForChar(chr1, chr2, currcs) {
    let result = [];
    let shifter = -1;

    if (charCompatible(chr1, currcs)) {
      if (currcs == CODESET.C) {
        if (chr2 == -1) {
          shifter = SET_CODEB;
          currcs = CODESET.B;
        } else if (chr2 != -1 && !charCompatible(chr2, currcs)) {
          //need to check ahead as well
          if (charCompatible(chr2, CODESET.A)) {
            shifter = SET_CODEA;
            currcs = CODESET.A;
          } else {
            shifter = SET_CODEB;
            currcs = CODESET.B;
          }
        }
      }
    } else {
      //if there is a next char AND that next char is also not compatible
      if (chr2 != -1 && !charCompatible(chr2, currcs)) {
        //need to switch code sets
        switch (currcs) {
          case CODESET.A:
            shifter = SET_CODEB;
            currcs = CODESET.B;
            break;
          case CODESET.B:
            shifter = SET_CODEA;
            currcs = CODESET.A;
            break;
        }
      } else {
        //no need to shift code sets, a temporary SHIFT will suffice
        shifter = SET_SHIFT;
      }
    }

    //ok some type of shift is nessecary
    if (shifter != -1) {
      result.push(shifter);
      result.push(codeValue(chr1));
    } else {
      if (currcs == CODESET.C) {
        //include next as well
        result.push(codeValue(chr1, chr2));
      } else {
        result.push(codeValue(chr1));
      }
    }
    barc.currcs = currcs;

    return result;
  }
//chr2 is the next byte to process. looks ahead.
chr2 is the next byte to process. looks ahead.
chr2 is the next byte to process . looks ahead .
function codesForChar(chr1, chr2, currcs) {
    let result = [];
    let shifter = -1;
    if (charCompatible(chr1, currcs)) {
      if (currcs == CODESET.C) {
        if (chr2 == -1) {
          shifter = SET_CODEB;
          currcs = CODESET.B;
        } else if (chr2 != -1 && !charCompatible(chr2, currcs)) {
          if (charCompatible(chr2, CODESET.A)) {
            shifter = SET_CODEA;
            currcs = CODESET.A;
          } else {
            shifter = SET_CODEB;
            currcs = CODESET.B;
          }
        }
      }
    } else {
      if (chr2 != -1 && !charCompatible(chr2, currcs)) {
        switch (currcs) {
          case CODESET.A:
            shifter = SET_CODEB;
            currcs = CODESET.B;
            break;
          case CODESET.B:
            shifter = SET_CODEA;
            currcs = CODESET.A;
            break;
        }
      } else {
        shifter = SET_SHIFT;
      }
    }
    if (shifter != -1) {
      result.push(shifter);
      result.push(codeValue(chr1));
    } else {
      if (currcs == CODESET.C) {
        result.push(codeValue(chr1, chr2));
      } else {
        result.push(codeValue(chr1));
      }
    }
    barc.currcs = currcs;
    return result;
  }
function codesForChar ( chr1 , chr2 , currcs ) { let result = [ ] ; let shifter = - 1 ; if ( charCompatible ( chr1 , currcs ) ) { if ( currcs == CODESET . C ) { if ( chr2 == - 1 ) { shifter = SET_CODEB ; currcs = CODESET . B ; } else if ( chr2 != - 1 && ! charCompatible ( chr2 , currcs ) ) { if ( charCompatible ( chr2 , CODESET . A ) ) { shifter = SET_CODEA ; currcs = CODESET . A ; } else { shifter = SET_CODEB ; currcs = CODESET . B ; } } } } else { if ( chr2 != - 1 && ! charCompatible ( chr2 , currcs ) ) { switch ( currcs ) { case CODESET . A : shifter = SET_CODEB ; currcs = CODESET . B ; break ; case CODESET . B : shifter = SET_CODEA ; currcs = CODESET . A ; break ; } } else { shifter = SET_SHIFT ; } } if ( shifter != - 1 ) { result . push ( shifter ) ; result . push ( codeValue ( chr1 ) ) ; } else { if ( currcs == CODESET . C ) { result . push ( codeValue ( chr1 , chr2 ) ) ; } else { result . push ( codeValue ( chr1 ) ) ; } } barc . currcs = currcs ; return result ; }
chr2 is the next byte to process.
chr2 is the next byte to process .
//need to check ahead as well //if there is a next char AND that next char is also not compatible //need to switch code sets //no need to shift code sets, a temporary SHIFT will suffice //ok some type of shift is nessecary //include next as well