1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_RTL_CHARACTER_HXX
21 #define INCLUDED_RTL_CHARACTER_HXX
23 #include "sal/config.h"
25 #include "sal/types.h"
29 /** Check for ASCII character.
31 @param nUtf32 A Unicode scalar value (represented as a UTF-32 code unit).
33 @return True if nChar is a ASCII character (0x00--0x7F).
35 @since LibreOffice 4.1
37 inline bool isAscii(sal_uInt32 nUtf32
)
39 return nUtf32
<= 0x7F;
42 /** Check for ASCII lower case character.
44 @param nUtf32 A Unicode scalar value (represented as a UTF-32 code unit).
46 @return True if nChar is a US-ASCII lower case alphabetic character
49 @since LibreOffice 4.1
51 inline bool isAsciiLowerCase(sal_uInt32 nUtf32
)
53 return nUtf32
>= 'a' && nUtf32
<= 'z';
56 /** Check for US-ASCII upper case character.
58 @param nUtf32 A Unicode scalar value (represented as a UTF-32 code unit).
60 @return True if nChar is a US-ASCII upper case alphabetic character
63 @since LibreOffice 4.1
65 inline bool isAsciiUpperCase(sal_uInt32 nUtf32
)
67 return nUtf32
>= 'A' && nUtf32
<= 'Z';
70 /** Check for ASCII alphanumeric character.
72 @param nUtf32 A Unicode scalar value (represented as a UTF-32 code unit).
74 @return True if nUtf32 is a US-ASCII alphanumeric character
75 (ASCII '0'--'9', 'A'--'Z' or 'a'--'z').
77 @since LibreOffice 4.1
79 inline bool isAsciiAlpha(sal_uInt32 nUtf32
)
81 return isAsciiLowerCase(nUtf32
) || isAsciiUpperCase(nUtf32
);
84 /** Check for ASCII digit character.
86 @param nUtf32 A Unicode scalar value (represented as a UTF-32 code unit).
88 @return True if nChar is a ASCII (decimal) digit character
91 @since LibreOffice 4.1
93 inline bool isAsciiDigit(sal_uInt32 nUtf32
)
95 return nUtf32
>= '0' && nUtf32
<= '9';
98 /** Check for US-ASCII alphanumeric character.
100 @param nUtf32 A Unicode scalar value (represented as a UTF-32 code unit).
102 @return True if nChar is a US-ASCII alphanumeric character (US-ASCII
103 '0'--'9', 'A'--'Z' or 'a'--'z').
105 @since LibreOffice 4.1
107 inline bool isAsciiAlphanumeric(sal_uInt32 nUtf32
)
109 return isAsciiDigit(nUtf32
) || isAsciiAlpha(nUtf32
);
112 /** Check for US-ASCII canonic hexadecimal digit character.
114 @param nUtf32 A Unicode scalar value (represented as a UTF-32 code unit).
116 @return True if nChar is a US-ASCII canonic (i.e., upper case)
117 hexadecimal digit character (US-ASCII '0'--'9' or 'A'--'F').
119 @since LibreOffice 4.1
121 inline bool isAsciiCanonicHexDigit(sal_uInt32 nUtf32
)
123 return isAsciiDigit(nUtf32
) || (nUtf32
>= 'A' && nUtf32
<= 'F');
126 /** Check for US-ASCII hexadecimal digit character.
128 @param nUtf32 A Unicode scalar value (represented as a UTF-32 code unit).
130 @return True if nChar is a US-ASCII hexadecimal digit character (US-
131 ASCII '0'--'9', 'A'--'F', 'a'--'f').
133 @since LibreOffice 4.1
135 inline bool isAsciiHexDigit(sal_uInt32 nUtf32
)
137 return isAsciiCanonicHexDigit(nUtf32
) || (nUtf32
>= 'a' && nUtf32
<= 'f');
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */