Skip to main content

Module encoding

Module encoding 

Source
Expand description

Commit encoding helpers for non-UTF-8 commit messages.

Functions§

decode_bytes
Decode bytes using Git’s encoding name, or lossy UTF-8 if unknown.
encode_header_text
Encode a single header field (author/committer line) without adding a trailing newline.
encode_unicode
Encode unicode for storage in a commit message body using Git’s encoding name.
ensure_body_trailing_newline
Git stores the commit message body with a trailing newline when non-empty.
finalize_stored_commit_message
Prepare a commit message for storage per i18n.commitEncoding (or equivalent).
find_invalid_utf8
Find the offset of the first byte that is not part of a strictly valid UTF-8 sequence, mirroring Git’s find_invalid_utf8 (commit.c).
identity_raw_for_serialized_commit
Raw author / committer header payloads for a new commit object.
is_strict_utf8
Whether buf is strictly valid UTF-8 per Git’s rules (see find_invalid_utf8).
resolve
Resolve an encoding label the way Git uses it in config and commit objects.