@@ -59,27 +59,47 @@ extension Character {
5959
6060 /// Returns whether the receiver is a valid Unicode lowercase character ([a-z])
6161 public var isLower : Bool {
62- return iswlower ( Int32 ( self . unicodeValue) ) != 0
62+ #if os(Linux)
63+ return islower ( Int32 ( self . unicodeValue) ) != 0
64+ #else
65+ return iswlower ( Int32 ( self . unicodeValue) ) != 0
66+ #endif
6367 }
6468
6569 /// Returns whether the receiver is a valid Unicode uppercase character ([A-Z])
6670 public var isUpper : Bool {
67- return iswupper ( Int32 ( self . unicodeValue) ) != 0
71+ #if os(Linux)
72+ return isupper ( Int32 ( self . unicodeValue) ) != 0
73+ #else
74+ return iswupper ( Int32 ( self . unicodeValue) ) != 0
75+ #endif
6876 }
6977
7078 /// Returns whether the receiver is a Unicode space character.
7179 public var isSpace : Bool {
72- return iswspace ( Int32 ( self . unicodeValue) ) != 0
80+ #if os(Linux)
81+ return isspace ( Int32 ( self . unicodeValue) ) != 0
82+ #else
83+ return iswspace ( Int32 ( self . unicodeValue) ) != 0
84+ #endif
7385 }
7486
7587 /// Returns whether the receiver is a Latin1 control character.
7688 public var isControl : Bool {
77- return iswcntrl ( Int32 ( self . unicodeValue) ) != 0
89+ #if os(Linux)
90+ return iscntrl ( Int32 ( self . unicodeValue) ) != 0
91+ #else
92+ return iswcntrl ( Int32 ( self . unicodeValue) ) != 0
93+ #endif
7894 }
7995
8096 /// Returns whether the receiver is a printable Unicode character.
8197 public var isPrintable : Bool {
82- return iswprint ( Int32 ( self . unicodeValue) ) != 0
98+ #if os(Linux)
99+ return isprint ( Int32 ( self . unicodeValue) ) != 0
100+ #else
101+ return iswprint ( Int32 ( self . unicodeValue) ) != 0
102+ #endif
83103 }
84104
85105 /// Converts the receiver to its corresponding uppercase letter, if any.
@@ -131,36 +151,64 @@ extension UnicodeScalar {
131151
132152 /// Returns whether the receiver is a valid Unicode lowercase character ([a-z])
133153 public var isLower : Bool {
134- return iswlower ( Int32 ( self . value) ) != 0
154+ #if os(Linux)
155+ return islower ( Int32 ( self . value) ) != 0
156+ #else
157+ return iswlower ( Int32 ( self . value) ) != 0
158+ #endif
135159 }
136160
137161 /// Returns whether the receiver is a valid Unicode uppercase character ([A-Z])
138162 public var isUpper : Bool {
139- return iswupper ( Int32 ( self . value) ) != 0
163+ #if os(Linux)
164+ return isupper ( Int32 ( self . value) ) != 0
165+ #else
166+ return iswupper ( Int32 ( self . value) ) != 0
167+ #endif
140168 }
141169
142170 /// Returns whether the receiver is a Unicode space character.
143171 public var isSpace : Bool {
144- return iswspace ( Int32 ( self . value) ) != 0 || self == " \u{21A1} " || self == " \u{000B} "
172+ #if os(Linux)
173+ return isspace ( Int32 ( self . value) ) != 0 || self == " \u{21A1} " || self == " \u{000B} "
174+ #else
175+ return iswspace ( Int32 ( self . value) ) != 0 || self == " \u{21A1} " || self == " \u{000B} "
176+ #endif
145177 }
146178
147179 /// Returns whether the receiver is a Latin1 control character.
148180 public var isControl : Bool {
149- return iswcntrl ( Int32 ( self . value) ) != 0
181+ #if os(Linux)
182+ return iscntrl ( Int32 ( self . value) ) != 0
183+ #else
184+ return iswcntrl ( Int32 ( self . value) ) != 0
185+ #endif
150186 }
151187
152188 /// Returns whether the receiver is a printable Unicode character.
153189 public var isPrintable : Bool {
154- return iswprint ( Int32 ( self . value) ) != 0
190+ #if os(Linux)
191+ return isprint ( Int32 ( self . value) ) != 0
192+ #else
193+ return iswprint ( Int32 ( self . value) ) != 0
194+ #endif
155195 }
156196
157197 /// Converts the receiver to its corresponding uppercase letter, if any.
158198 public var toUpper : UnicodeScalar {
159- return UnicodeScalar ( UInt32 ( towupper ( Int32 ( self . value) ) ) ) !
199+ #if os(Linux)
200+ return UnicodeScalar ( UInt32 ( toupper ( Int32 ( self . value) ) ) ) !
201+ #else
202+ return UnicodeScalar ( UInt32 ( towupper ( Int32 ( self . value) ) ) ) !
203+ #endif
160204 }
161205
162206 /// Converts the receiver to its corresponding lowercase letter, if any.
163207 public var toLower : UnicodeScalar {
164- return UnicodeScalar ( UInt32 ( towlower ( Int32 ( self . value) ) ) ) !
208+ #if os(Linux)
209+ return UnicodeScalar ( UInt32 ( tolower ( Int32 ( self . value) ) ) ) !
210+ #else
211+ return UnicodeScalar ( UInt32 ( towlower ( Int32 ( self . value) ) ) ) !
212+ #endif
165213 }
166214}
0 commit comments