]> git.proxmox.com Git - libgit2.git/blob - src/win32/utf-conv.h
6090a4b356a624eced776f3135e482ca3ccf5aa4
[libgit2.git] / src / win32 / utf-conv.h
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7 #ifndef INCLUDE_win32_utf_conv_h__
8 #define INCLUDE_win32_utf_conv_h__
9
10 #include "common.h"
11
12 #include <wchar.h>
13
14 #ifndef WC_ERR_INVALID_CHARS
15 # define WC_ERR_INVALID_CHARS 0x80
16 #endif
17
18 /**
19 * Converts a UTF-8 string to wide characters.
20 *
21 * @param dest The buffer to receive the wide string.
22 * @param dest_size The size of the buffer, in characters.
23 * @param src The UTF-8 string to convert.
24 * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure
25 */
26 int git__utf8_to_16(wchar_t *dest, size_t dest_size, const char *src);
27
28 /**
29 * Converts a wide string to UTF-8.
30 *
31 * @param dest The buffer to receive the UTF-8 string.
32 * @param dest_size The size of the buffer, in bytes.
33 * @param src The wide string to convert.
34 * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure
35 */
36 int git__utf16_to_8(char *dest, size_t dest_size, const wchar_t *src);
37
38 /**
39 * Converts a UTF-8 string to wide characters.
40 * Memory is allocated to hold the converted string.
41 * The caller is responsible for freeing the string with git__free.
42 *
43 * @param dest Receives a pointer to the wide string.
44 * @param src The UTF-8 string to convert.
45 * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure
46 */
47 int git__utf8_to_16_alloc(wchar_t **dest, const char *src);
48
49 /**
50 * Converts a wide string to UTF-8.
51 * Memory is allocated to hold the converted string.
52 * The caller is responsible for freeing the string with git__free.
53 *
54 * @param dest Receives a pointer to the UTF-8 string.
55 * @param src The wide string to convert.
56 * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure
57 */
58 int git__utf16_to_8_alloc(char **dest, const wchar_t *src);
59
60 #endif