Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Platform/Windows/CodePage.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Characters_Platform_Windows_CodePage_h_
5#define _Stroika_Foundation_Characters_Platform_Windows_CodePage_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#if qStroika_Foundation_Common_Platform_Windows
10#include <Windows.h>
11
12#include <OAIdl.h>
13#include <wtypes.h>
14#else
15#error "WINDOWS REQUIRED FOR THIS MODULE"
16#endif
17
19#include "Stroika/Foundation/Common/Common.h"
20
22
24
25 void WideStringToNarrow (const wchar_t* wsStart, const wchar_t* wsEnd, CodePage codePage, string* intoResult);
26 void NarrowStringToWide (const char* sStart, const char* sEnd, CodePage codePage, wstring* intoResult);
27
28 string BSTRStringToUTF8 (const BSTR bstr);
29 BSTR UTF8StringToBSTR (const char* ws);
30 wstring BSTR2wstring (BSTR b);
31 wstring BSTR2wstring (VARIANT b);
32
33 /*
34 @METHOD: Win32CharSetToCodePage
35 @DESCRIPTION: <p>Map from a Win32 lfCharset enumeration (as appears in RTF font specifications and LOGFONT specifications)
36 This routine is made portable to other platforms BECAUSE it is used in RTF files.
37 This function returns the magic code page # zero (CP_ACP on windows) if there is no good mapping.</p>
38
39 From https://msdn.microsoft.com/en-us/library/windows/desktop/dd145037(v=vs.85).aspx - we have that lfCharset is a BYTE (8 bits unsigned)
40 */
41 CodePage Win32CharSetToCodePage (uint8_t lfCharSet);
42
43 /*
44 @METHOD: Win32PrimaryLangIDToCodePage
45 @DESCRIPTION: <p>Map from a Win32 language identifier to a code page.</p>
46 */
47 CodePage Win32PrimaryLangIDToCodePage (USHORT languageIdenifier);
48
49 class PlatformCodePageConverter {
50 public:
51 PlatformCodePageConverter (CodePage codePage);
52
53 public:
54 nonvirtual void MapToUNICODE (const char* inMBChars, size_t inMBCharCnt, wchar_t* outChars, size_t* outCharCnt) const;
55 nonvirtual void MapFromUNICODE (const wchar_t* inChars, size_t inCharCnt, char* outChars, size_t* outCharCnt) const;
56
57 private:
58 CodePage fCodePage_;
59 };
60
61}
62
63/*
64 ********************************************************************************
65 ***************************** Implementation Details ***************************
66 ********************************************************************************
67 */
68#include "CodePage.inl"
69
70#endif /*_Stroika_Foundation_Characters_Platform_Windows_CodePage_h_*/