Lines Matching +full:is +full:- +full:number
7 // http://www.apache.org/licenses/LICENSE-2.0
10 // distributed under the License is distributed on an "AS IS" BASIS,
51 // be provided using CLDR two-letter region-code format. These should be in
52 // upper-case. The list of the codes can be found here:
68 // This type is neither copyable nor movable.
76 // in ITU-T Recommendation E.123. However we follow local conventions such as
77 // using '-' instead of whitespace as separators. For example, the number of
80 // format is as per INTERNATIONAL format but with no formatting applied e.g.
81 // "+41446681800". RFC3966 is as per INTERNATIONAL format, but with all spaces
83 // number extension appended with ";ext=". It also will have a prefix of
84 // "tel:" added, e.g. "tel:+41-44-668-1800".
98 // In some regions (e.g. the USA), it is impossible to distinguish between
99 // fixed-line and mobile numbers by looking at the phone number itself.
104 // The cost of this call is shared between the caller and the recipient, and
105 // is hence typically less than PREMIUM_RATE calls. See
110 // A personal number is associated with a particular person, and may be
111 // routed to either a MOBILE or FIXED_LINE number. Some more information can
116 // further routed to specific offices, but allow one number to be used for a
121 // A phone number is of type UNKNOWN when it does not fit any of the known
128 // Types of phone number matches. See detailed description beside the
151 // Possible outcomes when testing if a PhoneNumber is possible.
153 // The number length matches that of valid numbers for this region.
155 // The number length matches that of local numbers for this region only
160 // The number has an invalid country calling code.
162 // The number is shorter than all valid numbers for this region.
164 // The number is longer than the shortest valid numbers for this region,
166 // itself have a number length that matches valid numbers for this region.
171 // The number is longer than all valid numbers for this region.
178 // @returns an unordered set of the two-letter region codes for every
185 // non-geographical entity the library supports
190 // both non-geographical entities (global network calling codes) and those
191 // used for geographical entities. This could be used to populate a drop-down
192 // box of country calling codes for a phone-number widget, for instance.
196 // Will not include FIXED_LINE_OR_MOBILE (if numbers for this non-geographical
205 // Returns the types for a country-code belonging to a non-geographical entity
208 // non-geographical entity could be classified as FIXED_LINE_OR_MOBILE, both
212 // known non-geographical entity.
217 // Gets a PhoneNumberUtil instance to carry out international phone number
218 // formatting, parsing, or validation. The instance is loaded with phone
219 // number metadata for a number of most commonly used regions, as specified by
222 // The PhoneNumberUtil is implemented as a singleton. Therefore, calling
226 // Returns true if the number is a valid vanity (alpha) number such as 800
227 // MICROSOFT. A valid vanity number will start with at least 3 digits and will
228 // have three or more alpha characters. This does not do region-specific
229 // checks - to work out if this number is actually valid for a region, it
232 bool IsAlphaNumber(const string& number) const;
234 // Converts all alpha characters in a number to their respective digits on
236 void ConvertAlphaCharactersInNumber(string* number) const;
238 // Normalizes a string of characters representing a phone number. This
239 // converts wide-ascii and arabic-indic numerals to European numerals, and
241 void NormalizeDigitsOnly(string* number) const;
243 // Normalizes a string of characters representing a phone number. This strips
245 // all non-ASCII digits).
246 void NormalizeDiallableCharsOnly(string* number) const;
248 // Gets the national significant number of a phone number. Note a national
249 // significant number doesn't contain a national prefix or any formatting.
250 void GetNationalSignificantNumber(const PhoneNumber& number,
255 // number into geographical area code and subscriber number. It works in such
256 // a way that the resultant subscriber number should be diallable, at least on
260 // PhoneNumber number;
261 // phone_util.Parse("16502530000", "US", &number);
263 // phone_util.GetNationalSignificantNumber(number,
268 // int area_code_length = phone_util.GetLengthOfGeographicalAreaCode(number);
278 // N.B.: area code is a very ambiguous concept, so the authors generally
283 // - geographical area codes change over time, and this method honors those
286 // - subscriber numbers may not be diallable from all devices (notably mobile
289 // - most non-geographical numbers have no area codes, including numbers
290 // from non-geographical entities.
291 // - some geographical numbers have no area codes.
292 int GetLengthOfGeographicalAreaCode(const PhoneNumber& number) const;
296 // significant number into NDC and subscriber number. The NDC of a phone
297 // number is normally the first group of digit(s) right after the country
298 // calling code when the number is formatted in the international format, if
299 // there is a subscriber number part that follows.
306 // PhoneNumber number;
307 // phone_util.Parse("16502530000", "US", &number);
309 // phone_util.GetNationalSignificantNumber(number,
315 // phone_util.GetLengthOfNationalDestinationCode(number);
328 int GetLengthOfNationalDestinationCode(const PhoneNumber& number) const;
331 // one, otherwise returns an empty string. A mobile token is a number inserted
332 // before the area code when dialing a mobile number from that country from
337 // Formats a phone number in the specified format using default rules. Note
338 // that this does not promise to produce a phone number that the user can
339 // dial from where they are - although we do format in either NATIONAL or
342 // same area who could potentially dial the number without area code.
343 void Format(const PhoneNumber& number,
347 // Formats a phone number in the specified format using client-defined
350 const PhoneNumber& number,
355 // Formats a phone number in national format for dialing using the carrier as
357 // regardless of whether the phone number already has a preferred domestic
359 // number in national format without any carrier code.
360 void FormatNationalNumberWithCarrierCode(const PhoneNumber& number,
364 // Formats a phone number in national format for dialing using the carrier as
366 // object passed in. If that is missing, use the fallback_carrier_code passed
367 // in instead. If there is no preferred_domestic_carrier_code, and the
368 // fallback_carrier_code contains an empty string, return the number in
372 // in should take precedence over the number's preferred_domestic_carrier_code
375 const PhoneNumber& number,
379 // Returns a number formatted in such a way that it can be dialed from a
380 // mobile phone in a specific region. If the number cannot be reached from
381 // the region (e.g. some countries block toll-free numbers from being called
384 const PhoneNumber& number,
389 // Formats a phone number for out-of-country dialing purposes.
393 // code). In those cases, no international prefix is used. For regions which
394 // have multiple international prefixes, the number in its INTERNATIONAL
397 const PhoneNumber& number,
401 // Formats a phone number using the original phone number format (e.g.
402 // INTERNATIONAL or NATIONAL) that the number is parsed from, provided that
403 // the number has been parsed with ParseAndKeepRawInput. Otherwise the number
404 // will be formatted in NATIONAL format. The original format is embedded in
405 // the country_code_source field of the PhoneNumber object passed in, which is
407 // pattern for the number, the method falls back to returning the raw input.
408 // When the number is an invalid number, the method returns the raw input when
409 // it is available.
410 void FormatInOriginalFormat(const PhoneNumber& number,
414 // Formats a phone number for out-of-country dialing purposes.
416 // Note that in this version, if the number was entered originally using alpha
417 // characters and this version of the number is stored in raw_input, this
418 // representation of the number will be used rather than the digit
420 // "-" and " ", will be retained.
423 // 1) This will not produce good results if the country calling code is both
424 // present in the raw input _and_ is the start of the national number. This
425 // is not a problem in the regions which typically use alpha numbers.
427 // grouping information within the first three digits of the national number,
430 // so this is not a huge problem - and will be fixed if it proves to be so.
432 const PhoneNumber& number,
436 // Attempts to extract a valid number from a phone number that is too long to
438 // version. If no valid number could be extracted, the PhoneNumber object
439 // passed in will not be modified. It returns true if a valid phone number can
441 bool TruncateTooLongNumber(PhoneNumber* number) const;
443 // Gets the type of a valid phone number, or UNKNOWN if it is invalid.
444 PhoneNumberType GetNumberType(const PhoneNumber& number) const;
446 // Tests whether a phone number matches a valid pattern. Note this doesn't
447 // verify the number is actually in use, which is impossible to tell by just
448 // looking at a number itself.
449 // It only verifies whether the parsed, canonicalised number is valid: not
450 // whether a particular series of digits entered by the user is diallable from
451 // the region provided when parsing. For example, the number +41 (0) 78 927
452 // 2696 can be parsed into a number with country code "41" and national
453 // significant number "789272696". This is valid, while the original string
454 // is not diallable.
455 bool IsValidNumber(const PhoneNumber& number) const;
457 // Tests whether a phone number is valid for a certain region. Note this
458 // doesn't verify the number is actually in use, which is impossible to tell
459 // by just looking at a number itself. If the country calling code is not the
461 // with false. After this, the specific number pattern rules for the region
463 // This is useful for determining for example whether a particular number is
464 // valid for Canada, rather than just a valid NANPA number.
470 const PhoneNumber& number,
473 // Returns the region where a phone number is from. This could be used for
475 // full numbers (not short-codes, or invalid numbers).
476 void GetRegionCodeForNumber(const PhoneNumber& number,
484 // it is possible that several regions share the same country calling code
486 // the one with the largest population) is returned. If the
487 // countryCallingCode entered is valid but doesn't match a specific region
488 // (such as in the case of non-geographical calling codes like 800) the
494 // calling code. For non-geographical country calling codes, the region code
495 // 001 is returned. Also, in the case of no region code being found, the list
496 // is left unchanged.
501 // Checks if this is a region under the North American Numbering Plan
508 // for a dialling tone) from the prefix returned. If no national prefix is
514 // Checks whether a phone number is a possible number. It provides a more
517 // check starting digits of the number.
518 // 2. It doesn't attempt to figure out the type of the number, but uses
520 // region. Therefore, it is much faster than IsValidNumber().
521 // 3. For some numbers (particularly fixed-line), many regions have the
522 // concept of area code, which together with subscriber number constitute
523 // the national significant number. It is sometimes okay to dial only the
524 // subscriber number when dialing in the same area. This function will
525 // return IS_POSSIBLE_LOCAL_ONLY if the subscriber-number-only version is
530 // the subscriber-number-only version.
531 ValidationResult IsPossibleNumberWithReason(const PhoneNumber& number) const;
534 // returning the reason for failure, this method returns true if the number is
535 // either a possible fully-qualified number (containing the area code and
536 // country code), or if the number could be a possible local number (with a
539 // is needed for a call to connect, the number is not considered possible
541 bool IsPossibleNumber(const PhoneNumber& number) const;
543 // Check whether a phone number is a possible number of a particular type. For
545 // that isn't so useful; it is recommended that you use
548 // call it for this number at all.
554 // check starting digits of the number.
555 // 2. For some numbers (particularly fixed-line), many regions have the
556 // concept of area code, which together with subscriber number constitute
557 // the national significant number. It is sometimes okay to dial only the
558 // subscriber number when dialing in the same area. This function will
559 // return IS_POSSIBLE_LOCAL_ONLY if the subscriber-number-only version is
564 // the subscriber-number-only version.
566 const PhoneNumber& number, PhoneNumberType type) const;
569 // returning the reason for failure, this method returns true if the number is
570 // either a possible fully-qualified number (containing the area code and
571 // country code), or if the number could be a possible local number (with a
574 // is needed for a call to connect, the number is not considered possible
576 bool IsPossibleNumberForType(const PhoneNumber& number,
579 // Checks whether a phone number is a possible number given a number in the
580 // form of a string, and the country where the number could be dialed from.
582 // IsPossibleNumber(const PhoneNumber& number) for details.
584 // This method first parses the number, then invokes
585 // IsPossibleNumber(const PhoneNumber& number) with the resultant PhoneNumber
588 // region_dialing_from represents the region that we are expecting the number
589 // to be dialed from. Note this is different from the region where the number
590 // belongs. For example, the number +1 650 253 0000 is a number that belongs
592 // it is written as 00 1 650 253 0000, it could be dialed from any region
593 // which uses an international dialling prefix of 00. When it is written as
598 const string& number,
601 // Returns true if the number can be dialled from outside the region, or
602 // unknown. If the number can only be dialled from within the region, returns
603 // false. Does not check the number is a valid number. Note that, at the
606 bool CanBeInternationallyDialled(const PhoneNumber& number) const;
608 // Tests whether a phone number has a geographical association. It checks if
609 // the number is associated with a certain region in the country to which it
610 // belongs. Note that this doesn't verify if the number is actually in use.
614 // number type is expensive; if we have already done this, we don't want to do
619 // Gets a valid fixed-line number for the specified region. Returns false if
620 // the region was unknown, or the region 001 is passed in. For 001
621 // (representing non-geographical numbers), call
624 PhoneNumber* number) const;
626 // Gets an invalid number for the specified region. This is useful for
627 // unit-testing purposes, where you want to test that will happen with an
628 // invalid number. Note that the number that is returned will always be able
630 // *short* number/code for this region. Validity checking such
631 // numbers is handled with ShortNumberInfo.
633 // Returns false when an unsupported region or the region 001 (Earth) is
636 PhoneNumber* number) const;
638 // Gets a valid number of the specified type for the specified region.
639 // Returns false if the region was unknown or 001, or if no example number of
640 // that type could be found. For 001 (representing non-geographical numbers),
644 PhoneNumber* number) const;
646 // Gets a valid number for the specified type (it may belong to any country).
651 PhoneNumber* number) const;
653 // Gets a valid number for the specified country calling code for a
654 // non-geographical entity. Returns false if the metadata does not contain
656 // a non-geographical entity.
658 int country_calling_code, PhoneNumber* number) const;
660 // Parses a string and returns it as a phone number in proto buffer format.
661 // The method is quite lenient and looks for a number in the input text
662 // (raw input) and does not check whether the string is definitely only a
663 // phone number. To do this, it ignores punctuation and white-space, as well
664 // as any text before the number (e.g. a leading “Tel: ”) and trims the
665 // non-number bits. It will accept a number in any format (E164, national,
668 // if it thinks this is a vanity number of the type "1800 MICROSOFT".
670 // This method will return an error if the number is not considered to be a
671 // possible number, and NO_PARSING_ERROR if it is parsed correctly.
672 // Note that validation of whether the number is actually a valid number for
673 // a particular region is not performed. This can be done separately with
676 // Note this method canonicalizes the phone number such that different
679 // context about the number being parsed, such as the raw input that was
683 // number_to_parse can contain formatting such as +, ( and -, as well as a
684 // phone number extension. It can also be provided in RFC3966 format.
686 // default_region represents the country that we are expecting the number to
687 // be from. This is only used if the number being parsed is not written in
688 // international format. The country_code for the number in this case would be
689 // stored as that of the default country supplied. If the number is guaranteed
693 // Returns an error if the string is not considered to be a viable phone
694 // number (e.g.too few or too many digits) or if no default region was
695 // supplied and the number is not in international format (does not start with
699 PhoneNumber* number) const;
706 PhoneNumber* number) const;
715 // specified, or the country calling code specified is the same, and one NSN
716 // could be a shorter version of the other number. This includes the case
725 // is a convenience wrapper for IsNumberMatch(PhoneNumber firstNumber,
726 // PhoneNumber secondNumber). No default region is known.
727 // Returns INVALID_NUMBER if either number cannot be parsed into a phone
728 // number.
732 // Takes two phone numbers and compares them for equality. This is a
734 // PhoneNumber secondNumber). No default region is known.
736 // number.
747 // The deletion of the returned instance is under the responsibility of the
769 // The minimum and maximum length of the national significant number.
782 // is found as a placeholder for carrier information in some phone numbers.
783 // Full-width variants are also present.
787 // number for the purposes of parsing. This allows us to strip off parts of
788 // the number that are actually the start of another number, such as for:
789 // (530) 583-6985 x302/x2303 -> the second extension here makes this actually
790 // two phone numbers, (530) 583-6985 x302 and (530) 583-6985 x2303. We remove
791 // the second extension so that the first number is parsed correctly. The
792 // string preceding this is captured.
805 // country calling code 7. Under this map, 1 is mapped to region code "US" and
806 // 7 is mapped to region code "RU". This is implemented as a sorted vector to
818 // A mapping from a country calling code for a non-geographical entity to the
828 // in a number, for use when matching.
831 // Checks if a number matches the plus chars pattern.
832 bool StartsWithPlusCharsPattern(const string& number) const;
840 // Checks if a format is eligible to be used by the AsYouTypeFormatter. This
841 // method is here rather than in asyoutypeformatter.h since it depends on the
842 // valid punctuation declared by the phone number util.
850 // Trims unwanted end characters from a phone number string.
851 void TrimUnwantedEndChars(string* number) const;
853 // Helper function to check region code is not unknown or null.
856 // Helper function to check the country calling code is valid.
890 // Check if raw_input, which is assumed to be in the national format, has a
891 // national prefix. The national prefix is assumed to be in digits-only form.
897 bool HasFormattingPatternForNumber(const PhoneNumber& number) const;
901 void FormatNsn(const string& number,
906 void FormatNsnWithCarrier(const string& number,
913 const PhoneNumber& number,
919 const PhoneNumber& number,
923 // Strips the IDD from the start of the number if present. Helper function
925 bool ParsePrefixAsIdd(const RegExp& idd_pattern, string* number) const;
927 void Normalize(string* number) const;
931 string* number) const;
935 string* number,
938 void ExtractPossibleNumber(const string& number,
941 bool IsViablePhoneNumber(const string& number) const;
943 bool MaybeStripExtension(string* number, string* extension) const;
966 const string& number) const;