static getUtf8StringAt()

in src/engine/loaders/LoaderDicom.js [861:897]


  static getUtf8StringAt(dataView, offset, lengthBuf) {
    let str = '';
    let i = 0;
    while (i < lengthBuf) {
      let c = dataView.getUint8(offset + i);
      i++;
      if (c == 0x5e) {
        c = 32;
      }
      switch (c >> 4) {
        case 0:
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
        case 7:
          str += String.fromCharCode(c);
          break;
        case 12:
        case 13:
          const char2 = dataView.getUint8(offset + i);
          i++;
          str += String.fromCharCode(((c & 0x1f) << 6) | (char2 & 0x3f));
          break;
        case 14:
          const ch2 = dataView.getUint8(offset + i);
          i++;
          const ch3 = dataView.getUint8(offset + i);
          i++;
          str += String.fromCharCode(((c & 0x0f) << 12) | ((ch2 & 0x3f) << 6) | ((ch3 & 0x3f) << 0));
          break;
      } // switch
    } // while not end string
    return str;
  }