1 /* uc.h                                     -*- mode:c; coding:utf-8; -*-
2  *
3  *   Copyright (c) 2010-2021  Takashi Kato <ktakashi@ymail.com>
4  *
5  *   Redistribution and use in source and binary forms, with or without
6  *   modification, are permitted provided that the following conditions
7  *   are met:
8  *
9  *   1. Redistributions of source code must retain the above copyright
10  *      notice, this list of conditions and the following disclaimer.
11  *
12  *   2. Redistributions in binary form must reproduce the above copyright
13  *      notice, this list of conditions and the following disclaimer in the
14  *      documentation and/or other materials provided with the distribution.
15  *
16  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22  *   TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  *   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  *   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  *   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef SAGITTARIUS_UC_H_
30 #define SAGITTARIUS_UC_H_
31 
32 #include <sagittarius/config.h>
33 #include "sagittarius/platform.h"
34 
35 #if __STDC_VERSION__ >= 201112L
36 # if defined(HAVE_UCHAR_H) && defined(HAVE_CHAR32_T)
37 #  define SG_USE_UCHAR_FEATURE
38 # endif
39 #endif
40 
41 #if defined(USE_UCS4_CPP)
42 #  if defined(SG_USE_UCHAR_FEATURE) && !defined(SG_DONT_USE_UCS_LITERAL)
43 #   define UC_(x) U##x
44 #   define UC(x)  (const SgChar*)(UC_(x))
45 #  else
46 #   define UC(x)  (const SgChar*)(Sg_CharsToSgChars(x))
47 #  endif
48 SG_CDECL_BEGIN
49 SG_EXTERN const SgChar* Sg_CharsToSgChars(const char *str);
50 SG_CDECL_END
51 
52 #elif defined(SG_USE_UCHAR_FEATURE)
53 # define UC_(x) U##x
54 # define UC(x)  (const SgChar*)(UC_(x))
55 #elif defined(__CYGWIN__) || defined(_WIN32)
56 # define UC_(x) L##x
57 # define UC(x)  (const SgChar*)(UC_(x)L"\0")
58 #else
59 # define UC_(x) L##x
60 # define UC(x)  (const SgChar*)(UC_(x))
61 #endif
62 
63 #endif	/* SAGITTARIUS_UC_H_ */
64