Blender V4.3
utfconv.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2012 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#ifndef __UTFCONV_H__
10#define __UTFCONV_H__
11
12#include <stdio.h>
13#include <stdlib.h>
14#include <wchar.h>
15
21size_t count_utf_8_from_16(const wchar_t *string16);
22
28size_t count_utf_16_from_8(const char *string8);
29
30/*
31 * conv_utf_*** errors
32 */
33
35#define UTF_ERROR_NULL_IN (1 << 0)
37#define UTF_ERROR_ILLCHAR (1 << 1)
39#define UTF_ERROR_SMALL (1 << 2)
41#define UTF_ERROR_ILLSEQ (1 << 3)
42
50int conv_utf_16_to_8(const wchar_t *in16, char *out8, size_t size8);
51
59int conv_utf_8_to_16(const char *in8, wchar_t *out16, size_t size16);
60
67char *alloc_utf_8_from_16(const wchar_t *in16, size_t add);
68
76wchar_t *alloc_utf16_from_8(const char *in8, size_t add);
77
78/* Easy allocation and conversion of new utf-16 string. New string has _16 suffix.
79 * Must be deallocated with UTF16_UN_ENCODE in right order. */
80#define UTF16_ENCODE(in8str) \
81 if (1) { \
82 wchar_t *in8str##_16 = alloc_utf16_from_8((const char *)in8str, 0)
83
84#define UTF16_UN_ENCODE(in8str) \
85 free(in8str##_16); \
86 } \
87 (void)0
88
89#endif /* __UTFCONV_H__ */
wchar_t * alloc_utf16_from_8(const char *in8, size_t add)
Definition utfconv.cc:292
size_t count_utf_8_from_16(const wchar_t *string16)
Definition utfconv.cc:11
char * alloc_utf_8_from_16(const wchar_t *in16, size_t add)
Definition utfconv.cc:280
int conv_utf_8_to_16(const char *in8, wchar_t *out16, size_t size16)
Definition utfconv.cc:182
int conv_utf_16_to_8(const wchar_t *in16, char *out8, size_t size8)
Definition utfconv.cc:116
size_t count_utf_16_from_8(const char *string8)
Definition utfconv.cc:58