rcutils  master
C API providing common utilities and data structures.
isalnum_no_locale.h
Go to the documentation of this file.
1 // Copyright 2017 Open Source Robotics Foundation, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
16 
17 #ifndef RCUTILS__ISALNUM_NO_LOCALE_H_
18 #define RCUTILS__ISALNUM_NO_LOCALE_H_
19 
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
26 static inline
27 bool
28 rcutils_isalnum_no_locale(char c)
29 {
30  // if in '0', ..., '9', then ok
31  if (c >= 0x30 /*0*/ && c <= 0x39 /*9*/) {
32  return true;
33  }
34  // if in 'A', ..., 'Z', then ok
35  if (c >= 0x41 /*A*/ && c <= 0x5a /*Z*/) {
36  return true;
37  }
38  // if in 'a', ..., 'z', then ok
39  if (c >= 0x61 /*a*/ && c <= 0x7a /*z*/) {
40  return true;
41  }
42  return false;
43 }
44 
45 #ifdef __cplusplus
46 }
47 #endif
48 
49 #endif // RCUTILS__ISALNUM_NO_LOCALE_H_