Blame src/win32/utf-conv.h

Packit Service 20376f
/*
Packit Service 20376f
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit Service 20376f
 *
Packit Service 20376f
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit Service 20376f
 * a Linking Exception. For full terms see the included COPYING file.
Packit Service 20376f
 */
Packit Service 20376f
#ifndef INCLUDE_git_utfconv_h__
Packit Service 20376f
#define INCLUDE_git_utfconv_h__
Packit Service 20376f
Packit Service 20376f
#include <wchar.h>
Packit Service 20376f
#include "common.h"
Packit Service 20376f
Packit Service 20376f
#ifndef WC_ERR_INVALID_CHARS
Packit Service 20376f
# define WC_ERR_INVALID_CHARS	0x80
Packit Service 20376f
#endif
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Converts a UTF-8 string to wide characters.
Packit Service 20376f
 *
Packit Service 20376f
 * @param dest The buffer to receive the wide string.
Packit Service 20376f
 * @param dest_size The size of the buffer, in characters.
Packit Service 20376f
 * @param src The UTF-8 string to convert.
Packit Service 20376f
 * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure
Packit Service 20376f
 */
Packit Service 20376f
int git__utf8_to_16(wchar_t *dest, size_t dest_size, const char *src);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Converts a wide string to UTF-8.
Packit Service 20376f
 *
Packit Service 20376f
 * @param dest The buffer to receive the UTF-8 string.
Packit Service 20376f
 * @param dest_size The size of the buffer, in bytes.
Packit Service 20376f
 * @param src The wide string to convert.
Packit Service 20376f
 * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure
Packit Service 20376f
 */
Packit Service 20376f
int git__utf16_to_8(char *dest, size_t dest_size, const wchar_t *src);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Converts a UTF-8 string to wide characters.
Packit Service 20376f
 * Memory is allocated to hold the converted string.
Packit Service 20376f
 * The caller is responsible for freeing the string with git__free.
Packit Service 20376f
 *
Packit Service 20376f
 * @param dest Receives a pointer to the wide string.
Packit Service 20376f
 * @param src The UTF-8 string to convert.
Packit Service 20376f
 * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure
Packit Service 20376f
 */
Packit Service 20376f
int git__utf8_to_16_alloc(wchar_t **dest, const char *src);
Packit Service 20376f
Packit Service 20376f
/**
Packit Service 20376f
 * Converts a wide string to UTF-8.
Packit Service 20376f
 * Memory is allocated to hold the converted string.
Packit Service 20376f
 * The caller is responsible for freeing the string with git__free.
Packit Service 20376f
 *
Packit Service 20376f
 * @param dest Receives a pointer to the UTF-8 string.
Packit Service 20376f
 * @param src The wide string to convert.
Packit Service 20376f
 * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure
Packit Service 20376f
 */
Packit Service 20376f
int git__utf16_to_8_alloc(char **dest, const wchar_t *src);
Packit Service 20376f
Packit Service 20376f
#endif