1+ // Copyright (C) 2025 The Libphonenumber Authors
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+
15+ #include < stddef.h>
16+
17+ #ifndef I18N_PHONENUMBERS_CONSTANTS_H_
18+ #define I18N_PHONENUMBERS_CONSTANTS_H_
19+
20+ namespace i18n {
21+ namespace phonenumbers {
22+
23+ class Constants {
24+ friend class PhoneNumberMatcherRegExps ;
25+ friend class PhoneNumberRegExpsAndMappings ;
26+ friend class PhoneNumberUtil ;
27+
28+ private:
29+ // The kPlusSign signifies the international prefix.
30+ static constexpr char kPlusSign [] = " +" ;
31+
32+ static constexpr char kStarSign [] = " *" ;
33+
34+ static constexpr char kRfc3966ExtnPrefix [] = " ;ext=" ;
35+ static constexpr char kRfc3966VisualSeparator [] = " [\\ -\\ .\\ (\\ )]?" ;
36+
37+ static constexpr char kDigits [] = " \\ p{Nd}" ;
38+
39+ // We accept alpha characters in phone numbers, ASCII only. We store
40+ // lower-case here only since our regular expressions are case-insensitive.
41+ static constexpr char kValidAlpha [] = " a-z" ;
42+ static constexpr char kValidAlphaInclUppercase [] = " A-Za-z" ;
43+
44+ static constexpr char kPossibleSeparatorsBetweenNumberAndExtLabel [] =
45+ " [ \xC2\xA0\\ t,]*" ;
46+
47+ // Optional full stop (.) or colon, followed by zero or more
48+ // spaces/tabs/commas.
49+ static constexpr char kPossibleCharsAfterExtLabel [] =
50+ " [:\\ .\xEF\xBC\x8E ]?[ \xC2\xA0\\ t,-]*" ;
51+
52+ static constexpr char kOptionalExtSuffix [] = " #?" ;
53+
54+ // The minimum and maximum length of the national significant number.
55+ static constexpr size_t kMinLengthForNsn = 2 ;
56+
57+ static constexpr char kPlusChars [] = " +\xEF\xBC\x8B " ; /* "++" */
58+
59+ // Regular expression of acceptable punctuation found in phone numbers, used
60+ // to find numbers in text and to decide what is a viable phone number. This
61+ // excludes diallable characters.
62+ // This consists of dash characters, white space characters, full stops,
63+ // slashes, square brackets, parentheses and tildes. It also includes the
64+ // letter 'x' as that is found as a placeholder for carrier information in
65+ // some phone numbers. Full-width variants are also present. To find out the
66+ // unicode code-point of the characters below in vim, highlight the character
67+ // and type 'ga'. Note that the - is used to express ranges of full-width
68+ // punctuation below, as well as being present in the expression itself. In
69+ // emacs, you can use M-x unicode-what to query information about the unicode
70+ // character.
71+ static constexpr char kValidPunctuation [] =
72+ /* "-x‐-―−ー--/ <U+200B><U+2060> ()()[].\\[\\]/~⁓∼" */
73+ " -x\xE2\x80\x90 -\xE2\x80\x95\xE2\x88\x92\xE3\x83\xBC\xEF\xBC\x8D -\xEF\xBC "
74+ " \x8F \xC2\xA0\xC2\xAD\xE2\x80\x8B\xE2\x81\xA0\xE3\x80\x80 ()\xEF\xBC\x88 "
75+ " \xEF\xBC\x89\xEF\xBC\xBB\xEF\xBC\xBD .\\ [\\ ]/~\xE2\x81\x93\xE2\x88\xBC " ;
76+
77+ static constexpr char kCaptureUpToSecondNumberStart [] = " (.*)[\\\\ /] *x" ;
78+ };
79+
80+ } // namespace phonenumbers
81+ } // namespace i18n
82+
83+ #endif // I18N_PHONENUMBERS_CONSTANTS_H_
0 commit comments