Strip whitespace from the end of a string.
+`strbuf_reencode`::
+
+ Replace the contents of the strbuf with a reencoded form. Returns -1
+ on error, 0 on success.
+
`strbuf_cmp`::
Compare two buffers. Returns an integer less than, equal to, or greater
#include "cache.h"
#include "refs.h"
+#include "utf8.h"
int starts_with(const char *str, const char *prefix)
{
sb->buf[sb->len] = '\0';
}
+int strbuf_reencode(struct strbuf *sb, const char *from, const char *to)
+{
+ char *out;
+ int len;
+
+ if (same_encoding(from, to))
+ return 0;
+
+ out = reencode_string_len(sb->buf, sb->len, to, from, &len);
+ if (!out)
+ return -1;
+
+ strbuf_attach(sb, out, len, len);
+ return 0;
+}
+
struct strbuf **strbuf_split_buf(const char *str, size_t slen,
int terminator, int max)
{
extern void strbuf_trim(struct strbuf *);
extern void strbuf_rtrim(struct strbuf *);
extern void strbuf_ltrim(struct strbuf *);
+extern int strbuf_reencode(struct strbuf *sb, const char *from, const char *to);
extern int strbuf_cmp(const struct strbuf *, const struct strbuf *);
/*