如何使用国际格式的libphonenumber格式化电话号码. [英] How to format a phone numbers with libphonenumber in International format.
本文介绍了如何使用国际格式的libphonenumber格式化电话号码.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Github上libphonenumber提供的文档中,有一个
In the documentation provided by libphonenumber on Github, there is a demo, which converts any provided number into International Format, e.g +4915213116250
is converted into +49 1521 3116250
我想在C#中使用相同的功能.
I want to use the same functionality in C#.
在libphone的文档中,需要解析数字并提供国家/地区.但是该演示无法在不提供地区/国家的情况下运行.可以让我知道它是怎么做的吗?
In the documentation of libphone, there is need to parse the number and provide the countries/regions. But the demo works without providing the region/country. Can some body let me know how it is done?
推荐答案
您尝试过吗?
var phoneUtil = PhoneNumberUtil.GetInstance();
var numberProto = phoneUtil.Parse("1234567890", "IT");
var formattedPhone = phoneUtil.Format(numberProto, PhoneNumberFormat.INTERNATIONAL);
这将为您提供"+39 123 456 7890"
这篇关于如何使用国际格式的libphonenumber格式化电话号码.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文