MCPcopy Create free account
hub / github.com/libgit2/pygit2 / to_unicode_n

Function to_unicode_n

src/utils.h:69–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67PYGIT2_FN_UNUSED
68Py_LOCAL_INLINE(PyObject*)
69to_unicode_n(const char *value, size_t len, const char *encoding,
70 const char *errors)
71{
72 if (encoding == NULL) {
73 encoding = "utf-8"; // Default to UTF-8
74
75 /* If the encoding is not explicit, it may not be UTF-8, so it is not
76 * safe to decode it strictly. This is rare in the wild, but does
77 * occur in old commits to git itself (e.g. c31820c2).
78 * https://github.com/libgit2/pygit2/issues/77
79 */
80 if (errors == NULL) {
81 errors = "replace";
82 }
83 }
84
85 return PyUnicode_Decode(value, len, encoding, errors);
86}
87
88#define value_or_default(x, _default) ((x) == NULL ? (_default) : (x))
89

Callers 10

git_oid_to_py_strFunction · 0.85
Object_short_id__get__Function · 0.85
DiffLine_content__get__Function · 0.85
Diff_patch__get__Function · 0.85
DiffHunk_header__get__Function · 0.85
DiffStats_formatFunction · 0.85
Patch_text__get__Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…