netlog_viewer/netlog_viewer/log_view_painter.js
function writeHexString(bytes, out) {
    function byteToPaddedHex(b) {
      let str = b.toString(16).toUpperCase();
      if (str.length < 2) {
        str = '0' + str;
      }
      return str;
    }

    const kBytesPerLine = 16;
    // Returns pretty printed kBytesPerLine bytes starting from
    // bytes[startIndex], in hexdump style format.
    function formatLine(startIndex) {
      let result = ' ';

      // Append a hex formatting of |bytes|.
      for (let i = 0; i < kBytesPerLine; ++i) {
        result += ' ';

        // Add a separator every 8 bytes.
        if ((i % 8) === 0) {
          result += ' ';
        }

        // Output hex for the byte, or space if no bytes remain.
        const byteIndex = startIndex + i;
        if (byteIndex < bytes.length) {
          result += byteToPaddedHex(bytes[byteIndex]);
        } else {
          result += '  ';
        }
      }

      result += '   ';

      // Append an ASCII formatting of the bytes, where ASCII codes 32
      // though 126 display the corresponding characters, nulls are
      // represented by spaces, and any other character is represented
      // by a period.
      for (let i = 0; i < kBytesPerLine; ++i) {
        const byteIndex = startIndex + i;
        if (byteIndex >= bytes.length) {
          break;
        }

        const curByte = bytes[byteIndex];

        if (curByte >= 0x20 && curByte <= 0x7E) {
          result += String.fromCharCode(curByte);
        } else if (curByte === 0x00) {
          result += ' ';
        } else {
          result += '.';
        }
      }

      return result;
    }

    // Output lines for each group of kBytesPerLine bytes.
    for (let i = 0; i < bytes.length; i += kBytesPerLine) {
      out.writeLine(formatLine(i));
    }
  }
function writeHexString(bytes, out) {
    function byteToPaddedHex(b) {
      let str = b.toString(16).toUpperCase();
      if (str.length < 2) {
        str = '0' + str;
      }
      return str;
    }

    const kBytesPerLine = 16;
    // Returns pretty printed kBytesPerLine bytes starting from
    // bytes[startIndex], in hexdump style format.
    function formatLine(startIndex) {
      let result = ' ';

      // Append a hex formatting of |bytes|.
      for (let i = 0; i < kBytesPerLine; ++i) {
        result += ' ';

        // Add a separator every 8 bytes.
        if ((i % 8) === 0) {
          result += ' ';
        }

        // Output hex for the byte, or space if no bytes remain.
        const byteIndex = startIndex + i;
        if (byteIndex < bytes.length) {
          result += byteToPaddedHex(bytes[byteIndex]);
        } else {
          result += '  ';
        }
      }

      result += '   ';

      // Append an ASCII formatting of the bytes, where ASCII codes 32
      // though 126 display the corresponding characters, nulls are
      // represented by spaces, and any other character is represented
      // by a period.
      for (let i = 0; i < kBytesPerLine; ++i) {
        const byteIndex = startIndex + i;
        if (byteIndex >= bytes.length) {
          break;
        }

        const curByte = bytes[byteIndex];

        if (curByte >= 0x20 && curByte <= 0x7E) {
          result += String.fromCharCode(curByte);
        } else if (curByte === 0x00) {
          result += ' ';
        } else {
          result += '.';
        }
      }

      return result;
    }

    // Output lines for each group of kBytesPerLine bytes.
    for (let i = 0; i < bytes.length; i += kBytesPerLine) {
      out.writeLine(formatLine(i));
    }
  }
function writeHexString ( bytes , out ) { function byteToPaddedHex ( b ) { let str = b . toString ( 16 ) . toUpperCase ( ) ; if ( str . length < 2 ) { str = '0' + str ; } return str ; } const kBytesPerLine = 16 ; // Returns pretty printed kBytesPerLine bytes starting from // bytes[startIndex], in hexdump style format. function formatLine ( startIndex ) { let result = ' ' ; // Append a hex formatting of |bytes|. for ( let i = 0 ; i < kBytesPerLine ; ++ i ) { result += ' ' ; // Add a separator every 8 bytes. if ( ( i % 8 ) === 0 ) { result += ' ' ; } // Output hex for the byte, or space if no bytes remain. const byteIndex = startIndex + i ; if ( byteIndex < bytes . length ) { result += byteToPaddedHex ( bytes [ byteIndex ] ) ; } else { result += '  ' ; } } result += '   ' ; // Append an ASCII formatting of the bytes, where ASCII codes 32 // though 126 display the corresponding characters, nulls are // represented by spaces, and any other character is represented // by a period. for ( let i = 0 ; i < kBytesPerLine ; ++ i ) { const byteIndex = startIndex + i ; if ( byteIndex >= bytes . length ) { break ; } const curByte = bytes [ byteIndex ] ; if ( curByte >= 0x20 && curByte <= 0x7E ) { result += String . fromCharCode ( curByte ) ; } else if ( curByte === 0x00 ) { result += ' ' ; } else { result += '.' ; } } return result ; } // Output lines for each group of kBytesPerLine bytes. for ( let i = 0 ; i < bytes . length ; i += kBytesPerLine ) { out . writeLine ( formatLine ( i ) ) ; } }
|bytes| must be an array-like object of bytes.  Writes multiple lines to
|out| with the hexadecimal characters from |bytes| on the left, in
groups of two, and their corresponding ASCII characters on the
right.

16 bytes will be placed on each line of the output string, split into two
columns of 8.
|bytes| must be an array - like object of bytes . Writes multiple lines to |out| with the hexadecimal characters from |bytes| on the left in groups of two and their corresponding ASCII characters on the right .