code: def encode_katakana(text):
      
      encoded = []
      for char in text:
          if jaconv:
              # try to convert japanese text to half-katakanas
              char = jaconv.z2h(jaconv.hira2kata(char))
              # TODO: "the conversion may result in multiple characters"
              # If that really can happen (I am not really shure), than the string would have to be split and every single
              #  character has to passed through the following lines.
  
          if char in TXT_ENC_KATAKANA_MAP:
              encoded.append(TXT_ENC_KATAKANA_MAP[char])
          else:
              # TODO doesn't this discard all that is not in the map? Can we be sure that the input does contain only
              # encodable characters? We could at least throw an exception if encoding is not possible.
              pass
      return b"".join(encoded)
docs: I don't think this quite works yet.