]>
Commit | Line | Data |
---|---|---|
7998ae5a | 1 | /* |
359fc2d2 | 2 | * Copyright (C) the libgit2 contributors. All rights reserved. |
7998ae5a PB |
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 | */ | |
eae0bfdc PP |
7 | #ifndef INCLUDE_win32_utf_conv_h__ |
8 | #define INCLUDE_win32_utf_conv_h__ | |
7998ae5a | 9 | |
3869a171 | 10 | #include "common.h" |
7998ae5a | 11 | |
eae0bfdc PP |
12 | #include <wchar.h> |
13 | ||
cd39e4e2 ET |
14 | #ifndef WC_ERR_INVALID_CHARS |
15 | # define WC_ERR_INVALID_CHARS 0x80 | |
16 | #endif | |
17 | ||
c2c81615 PK |
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); | |
841034a3 | 27 | |
c2c81615 PK |
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 | */ | |
aaefbdee | 36 | int git__utf16_to_8(char *dest, size_t dest_size, const wchar_t *src); |
7998ae5a | 37 | |
c2c81615 PK |
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 | ||
aaefbdee | 60 | #endif |