Stroika Library 3.0d18
 
Loading...
Searching...
No Matches
SDKChar.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Characters_SDKChar_h_
5#define _Stroika_Foundation_Characters_SDKChar_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <type_traits>
10
11#if qStroika_Foundation_Common_Platform_Windows
12#include <tchar.h>
13#endif
14
15#include "Stroika/Foundation/Common/Common.h"
16
17/**
18 * Each platform SDK has its own policy for representing characters. Some use narrow characters (char),
19 * and a predefined code page (often configured via locale), and others use wide-characters (wchar_t unicode).
20 *
21 * SDKChar is the underlying representation of the SDK's characters - whether it be narrow or wide.
22 */
23
25
26 /**
27 * qTargetPlatformSDKUseswchar_t
28 *
29 * Defines if we use wchar_t or char for most platform interfaces (mostly applicable/useful for windows)
30 */
31#ifndef qTargetPlatformSDKUseswchar_t
32#if (defined(_UNICODE) || defined(UNICODE))
33#define qTargetPlatformSDKUseswchar_t 1
34#else
35#define qTargetPlatformSDKUseswchar_t 0
36#endif
37#endif
38
39// Then VALIDATE qTargetPlatformSDKUseswchar_t with respect to other common defines
40#if defined(_WINDOWS)
41#if qTargetPlatformSDKUseswchar_t
42#if !defined(_UNICODE) || !defined(UNICODE)
43#error "INCONSITENT VALS"
44#endif
45#else
46#if defined(_UNICODE) || defined(UNICODE)
47#error "INCONSITENT VALS"
48#endif
49#endif
50#endif
51
52 /**
53 * SDKChar is the kind of character passed to most/default platform SDK APIs.
54 *
55 * Platform-Specific Meaning:
56 * o Windows
57 * Typically this is wchar_t, which is char16_t-ish. Windows SDK also supports an older "A" API (active Code page single byte)
58 * which Stroika probably still supports, but this has not been tested in a while (not very useful, not used much anymore).
59 *
60 * o Unix
61 * There is no standard. This could be locale-dependent (often EUC based multibyte character sets).
62 * Or could be UTF-8. These aren't totally incompatible possibilities.
63 *
64 * o MacOS
65 * Same as 'Unix' above, but most typically UTF-8. So Stroika assumes UTF-8.
66 * See <https://stackoverflow.com/questions/3071377/saner-way-to-get-character-encoding-of-the-cli-in-mac-os-x>
67 *
68 * o Linux
69 * Same as 'Unix' above - default to assume locale{} based.
70 */
71 using SDKChar = conditional_t<qTargetPlatformSDKUseswchar_t, wchar_t, char>;
72
73}
74
75/*
76 ********************************************************************************
77 ***************************** Implementation Details ***************************
78 ********************************************************************************
79 */
80
81#include "SDKChar.inl"
82
83#endif /*_Stroika_Foundation_Characters_SDKChar_h_*/
conditional_t< qTargetPlatformSDKUseswchar_t, wchar_t, char > SDKChar
Definition SDKChar.h:71