protected function encodeInteger($value, $length) {
        $format = "%'.0" . $length . "d";
        $output = null === $value ? "" : sprintf($format, $value);
        if ($length < strlen($output)) {
            throw new TooLongDataException($value, $length);
        }
        return $output;
    }