fix handling broken unicode character hang
[platform/upstream/libphonenumber.git] / resources / phonenumber.proto
1 /*
2  * Copyright (C) 2009 The Libphonenumber Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 // Definition of protocol buffer for representing international telephone numbers.
18 // @author Shaopeng Jia
19
20 syntax = "proto2";
21
22 option java_package = "com.google.i18n.phonenumbers";
23 option optimize_for = LITE_RUNTIME;
24
25 package i18n.phonenumbers;
26
27 message PhoneNumber {
28 // The country calling code for this number, as defined by the International Telecommunication Union
29 // (ITU). Fox example, this would be 1 for NANPA countries, and 33 for France.
30   required int32 country_code = 1;
31
32 // National (significant) Number is defined in International Telecommunication Union (ITU)
33 // Recommendation E.164. It is a language/country-neutral representation of a phone number at a
34 // country level. For countries which have the concept of Area Code, the National (significant)
35 // Number contains the area code. It contains a maximum number of digits which equal to 15 - n,
36 // where n is the number of digits of the country code. Take note that National (significant) Number
37 // does not contain National(trunk) prefix. Obviously, as a uint64, it will never contain any
38 // formatting (hypens, spaces, parentheses), nor any alphanumeric spellings.
39   required uint64 national_number = 2;
40
41 // Extension is not standardized in ITU recommendations, except for being defined as a series of
42 // numbers with a maximum length of 40 digits. It is defined as a string here to accommodate for the
43 // possible use of a leading zero in the extension (organizations have complete freedom to do so,
44 // as there is no standard defined). However, only ASCII digits should be stored here.
45   optional string extension = 3;
46
47 // In some countries, the national (significant) number starts with one or more "0"s without this
48 // being a national prefix or trunk code of some kind. For example, the leading zero in the national
49 // (significant) number of an Italian phone number indicates the number is a fixed-line number.
50 // There have been plans to migrate fixed-line numbers to start with the digit two since December
51 // 2000, but it has not happened yet. See http://en.wikipedia.org/wiki/%2B39 for more details.
52 //
53 // These fields can be safely ignored (there is no need to set them) for most countries. Some
54 // limited number of countries behave like Italy - for these cases, if the leading zero(s) of a
55 // number would be retained even when dialling internationally, set this flag to true, and also
56 // set the number of leading zeros.
57 //
58 // Clients who use the parsing functionality of the i18n phone number libraries
59 // will have these fields set if necessary automatically.
60   optional bool italian_leading_zero = 4;
61   optional int32 number_of_leading_zeros = 8 [ default = 1 ];
62
63 // The next few fields are non-essential fields for a phone number. They retain extra information
64 // about the form the phone number was in when it was provided to us to parse. They can be safely
65 // ignored by most clients.
66
67 // This field is used to store the raw input string containing phone numbers before it was
68 // canonicalized by the library. For example, it could be used to store alphanumerical numbers
69 // such as "1-800-GOOG-411".
70   optional string raw_input = 5;
71
72 // The source from which the country_code is derived. This is not set in the general parsing method,
73 // but in the method that parses and keeps raw_input. New fields could be added upon request.
74   enum CountryCodeSource {
75     // The country_code is derived based on a phone number with a leading "+", e.g. the French
76     // number "+33 1 42 68 53 00".
77     FROM_NUMBER_WITH_PLUS_SIGN = 1;
78
79     // The country_code is derived based on a phone number with a leading IDD, e.g. the French
80     // number "011 33 1 42 68 53 00", as it is dialled from US.
81     FROM_NUMBER_WITH_IDD = 5;
82
83     // The country_code is derived based on a phone number without a leading "+", e.g. the French
84     // number "33 1 42 68 53 00" when defaultCountry is supplied as France.
85     FROM_NUMBER_WITHOUT_PLUS_SIGN = 10;
86
87     // The country_code is derived NOT based on the phone number itself, but from the defaultCountry
88     // parameter provided in the parsing function by the clients. This happens mostly for numbers
89     // written in the national format (without country code). For example, this would be set when
90     // parsing the French number "01 42 68 53 00", when defaultCountry is supplied as France.
91     FROM_DEFAULT_COUNTRY = 20;
92   }
93
94 // The source from which the country_code is derived.
95   optional CountryCodeSource country_code_source = 6;
96
97 // The carrier selection code that is preferred when calling this phone number domestically. This
98 // also includes codes that need to be dialed in some countries when calling from landlines to
99 // mobiles or vice versa. For example, in Columbia, a "3" needs to be dialed before the phone number
100 // itself when calling from a mobile phone to a domestic landline phone and vice versa.
101 //
102 // Note this is the "preferred" code, which means other codes may work as well.
103   optional string preferred_domestic_carrier_code = 7;
104 }
105
106 // Examples
107 //
108 // Google MTV, +1 650-253-0000, (650) 253-0000
109 // country_code: 1
110 // national_number: 6502530000
111 //
112 // Google Paris, +33 (0)1 42 68 53 00, 01 42 68 53 00
113 // country_code: 33
114 // national_number: 142685300
115 //
116 // Google Beijing, +86-10-62503000, (010) 62503000
117 // country_code: 86
118 // national_number: 1062503000
119 //
120 // Google Italy, +39 02-36618 300, 02-36618 300
121 // country_code: 39
122 // national_number: 236618300
123 // italian_leading_zero: true