Blame src/win32/utf-conv.h

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