from typing import List
from typing import Tuple
import struct


def vox_dict( entries: List[ Tuple[ str, str ] ] ) -> bytes:
  """Produces the binary representation of a dictionary for the .vox format.
  Note that all keys and values are strings.

  Examples
  --------
  >>> vox_dict( [ ( '_t', '10 5 2' ) ] )

  This dictionary (from the 'nTRN' chunk) defines a translation.
  """
  w = bytearray( )
  w.extend( struct.pack( '<I', len( entries ) ) )
  for (key, value) in entries:
    key_b = bytes( key, 'UTF-8' )
    value_b = bytes( value, 'UTF-8' )

    w.extend( struct.pack( '<I', len( key_b ) ) )
    w.extend( key_b )
    w.extend( struct.pack( '<I', len( value_b ) ) )
    w.extend( value_b )
  return bytes( w )