Created
September 26, 2017 17:19
-
-
Save 0xKD/8ce78109092c85ddec7602f3aae6ca5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include "phonenumbers/phonenumberutil.h" | |
using i18n::phonenumbers::PhoneNumber; | |
using i18n::phonenumbers::PhoneNumberUtil; | |
using namespace std; | |
const PhoneNumberUtil &util = *PhoneNumberUtil::GetInstance(); | |
string format_number(string phone) { | |
string formatted; | |
PhoneNumber number; | |
util.Parse(phone, "IN", &number); | |
util.Format(number, PhoneNumberUtil::E164, &formatted); | |
if (!util.IsValidNumber(number)) { | |
return ""; | |
} | |
return formatted; | |
} | |
int main() { | |
for (string line; getline(cin, line);) { | |
cout<<format_number(line)<<endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment