Keyple Util C++ Library 2.3.0.5-SNAPSHOT
Reference Terminal Reader API for C++
Character.h
Go to the documentation of this file.
1/**************************************************************************************************
2 * Copyright (c) 2021 Calypso Networks Association https://calypsonet.org/ *
3 * *
4 * See the NOTICE file(s) distributed with this work for additional information regarding *
5 * copyright ownership. *
6 * *
7 * This program and the accompanying materials are made available under the terms of the Eclipse *
8 * Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0 *
9 * *
10 * SPDX-License-Identifier: EPL-2.0 *
11 **************************************************************************************************/
12
13#pragma once
14
15namespace keyple {
16namespace core {
17namespace util {
18namespace cpp {
19
20class Character {
21public:
22 static char digit(char ch, int radix)
23 {
24 (void)radix;
25
26 if (ch >= '0' && ch <= '9')
27 return ch - '0';
28 if (ch >= 'A' && ch <= 'Z')
29 return ch - 'A' + 10;
30 if (ch >= 'a' && ch <= 'z')
31 return ch - 'a' + 10;
32
33 return 0;
34 }
35
39 static bool isWhitespace(char c)
40 {
41 return isWhitespace((int)c);
42 }
43
51 static bool isWhitespace(int codePoint)
52 {
53
54 if ((codePoint >= 0x1c && codePoint <= 0x20) ||
55 (codePoint >= 0x09 && codePoint <= 0x0d)) {
56 return true;
57 }
58 if (codePoint < 0x1000) {
59 return false;
60 }
61
62 /* OGHAM SPACE MARK or MONGOLIAN VOWEL SEPARATOR? */
63 if (codePoint == 0x1680 || codePoint == 0x180e) {
64 return true;
65 }
66 if (codePoint < 0x2000) {
67 return false;
68 }
69
70 /* Exclude General Punctuation's non-breaking spaces (which includes FIGURE SPACE). */
71 if (codePoint == 0x2007 || codePoint == 0x202f) {
72 return false;
73 }
74 if (codePoint <= 0xffff) {
75 /* Other whitespace from General Punctuation... */
76 return codePoint <= 0x200a || codePoint == 0x2028 ||
77 codePoint == 0x2029 || codePoint == 0x205f ||
78 codePoint == 0x3000; /* ...or CJK Symbols and Punctuation? */
79 }
80 /* Let icu4c worry about non-BMP code points. */
81 //return isWhitespaceImpl(codePoint);
82 return false;
83 }
84};
85
86}
87}
88}
89}
static bool isWhitespace(char c)
Definition: Character.h:39
static char digit(char ch, int radix)
Definition: Character.h:22
static bool isWhitespace(int codePoint)
Definition: Character.h:51