summaryrefslogtreecommitdiff
path: root/lib/chef/win32/api/unicode.rb
blob: 29cdfba5fd5b6931ed0566e431dae45b2018d99f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Copyright:: Copyright 2011 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require "chef/win32/api"

class Chef
  module ReservedNames::Win32
    module API
      module Unicode
        extend Chef::ReservedNames::Win32::API

        ###############################################
        # Win32 API Constants
        ###############################################

        CP_ACP         = 0
        CP_OEMCP       = 1
        CP_MACCP       = 2
        CP_THREAD_ACP  = 3
        CP_SYMBOL      = 42
        CP_UTF7        = 65000
        CP_UTF8        = 65001

        MB_PRECOMPOSED       = 0x00000001
        MB_COMPOSITE         = 0x00000002
        MB_USEGLYPHCHARS     = 0x00000004
        MB_ERR_INVALID_CHARS = 0x00000008

        WC_COMPOSITECHECK    = 0x00000200
        WC_DISCARDNS         = 0x00000010
        WC_SEPCHARS          = 0x00000020
        WC_DEFAULTCHAR       = 0x00000040
        WC_NO_BEST_FIT_CHARS = 0x00000400

        ANSI_CHARSET        = 0
        DEFAULT_CHARSET     = 1
        SYMBOL_CHARSET      = 2
        SHIFTJIS_CHARSET    = 128
        HANGEUL_CHARSET     = 129
        HANGUL_CHARSET      = 129
        GB2312_CHARSET      = 134
        CHINESEBIG5_CHARSET = 136
        OEM_CHARSET         = 255
        JOHAB_CHARSET       = 130
        HEBREW_CHARSET      = 177
        ARABIC_CHARSET      = 178
        GREEK_CHARSET       = 161
        TURKISH_CHARSET     = 162
        VIETNAMESE_CHARSET  = 163
        THAI_CHARSET        = 222
        EASTEUROPE_CHARSET  = 238
        RUSSIAN_CHARSET     = 204

        IS_TEXT_UNICODE_ASCII16            = 0x0001
        IS_TEXT_UNICODE_REVERSE_ASCII16    = 0x0010
        IS_TEXT_UNICODE_STATISTICS         = 0x0002
        IS_TEXT_UNICODE_REVERSE_STATISTICS = 0x0020
        IS_TEXT_UNICODE_CONTROLS           = 0x0004
        IS_TEXT_UNICODE_REVERSE_CONTROLS   = 0x0040
        IS_TEXT_UNICODE_SIGNATURE          = 0x0008
        IS_TEXT_UNICODE_REVERSE_SIGNATURE  = 0x0080
        IS_TEXT_UNICODE_ILLEGAL_CHARS      = 0x0100
        IS_TEXT_UNICODE_ODD_LENGTH         = 0x0200
        IS_TEXT_UNICODE_DBCS_LEADBYTE      = 0x0400
        IS_TEXT_UNICODE_NULL_BYTES         = 0x1000
        IS_TEXT_UNICODE_UNICODE_MASK       = 0x000F
        IS_TEXT_UNICODE_REVERSE_MASK       = 0x00F0
        IS_TEXT_UNICODE_NOT_UNICODE_MASK   = 0x0F00
        IS_TEXT_UNICODE_NOT_ASCII_MASK     = 0xF000

        TCI_SRCCHARSET  = 1
        TCI_SRCCODEPAGE = 2
        TCI_SRCFONTSIG  = 3
        TCI_SRCLOCALE   = 0x100

        ###############################################
        # Win32 API Bindings
        ###############################################

        ffi_lib "kernel32", "advapi32"

=begin
BOOL IsTextUnicode(
  __in     const VOID *lpv,
  __in     int iSize,
  __inout  LPINT lpiResult
);
=end
        safe_attach_function :IsTextUnicode, [:pointer, :int, :LPINT], :BOOL

=begin
int MultiByteToWideChar(
  __in   UINT CodePage,
  __in   DWORD dwFlags,
  __in   LPCSTR lpMultiByteStr,
  __in   int cbMultiByte,
  __out  LPWSTR lpWideCharStr,
  __in   int cchWideChar
);
=end
        safe_attach_function :MultiByteToWideChar, [:UINT, :DWORD, :LPCSTR, :int, :LPWSTR, :int], :int

=begin
int WideCharToMultiByte(
  __in   UINT CodePage,
  __in   DWORD dwFlags,
  __in   LPCWSTR lpWideCharStr,
  __in   int cchWideChar,
  __out  LPSTR lpMultiByteStr,
  __in   int cbMultiByte,
  __in   LPCSTR lpDefaultChar,
  __out  LPBOOL lpUsedDefaultChar
);
=end
        safe_attach_function :WideCharToMultiByte, [:UINT, :DWORD, :LPCWSTR, :int, :LPSTR, :int, :LPCSTR, :LPBOOL], :int

      end
    end
  end
end