Re: [PATCH v3 07/13] utf8.c: add reencode_string_len() that can handle NULs in string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nguyễn Thái Ngọc Duy  <pclouds@xxxxxxxxx> writes:

> diff --git a/utf8.h b/utf8.h
> index d3da96f..a43ef9a 100644
> --- a/utf8.h
> +++ b/utf8.h
> @@ -17,12 +17,25 @@ void strbuf_add_wrapped_bytes(struct strbuf *buf, const char *data, int len,
>  			     int indent, int indent2, int width);
>  
>  #ifndef NO_ICONV
> -char *reencode_string_iconv(const char *in, size_t insz, iconv_t conv);
> -char *reencode_string(const char *in, const char *out_encoding, const char *in_encoding);
> +char *reencode_string_iconv(const char *in, size_t insz,
> +			    iconv_t conv, int *outsz);
> +char *reencode_string_len(const char *in, int insz,
> +			  const char *out_encoding,
> +			  const char *in_encoding,
> +			  int *outsz);
>  #else
> -#define reencode_string(a,b,c) NULL
> +#define reencode_string_len(a,b,c,d,e) NULL
>  #endif
>  
> +static inline char *reencode_string(const char *in,
> +				    const char *out_encoding,
> +				    const char *in_encoding)
> +{
> +	return reencode_string_len(in, strlen(in),
> +				   out_encoding, in_encoding,
> +				   NULL);
> +}
> +
>  int mbs_chrlen(const char **text, size_t *remainder_p, const char *encoding);
>  
>  #endif

Nicely done.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]