是否有快速内置的方法将ALPHA-2(GB)转换为C#中的ALPHA-3(GBR),而无需创建所有数组.
我需要获取Web应用程序的有效国家/地区列表,是否有可以以XML或类似格式下载的列表,以便我可以自动更新国家/地区列表?
我从数据库中获取手机号码我有更多的1000手机号码,我的数据库看起来像这样
mobilenumber
971525478965
919844005522
45712345678
Run Code Online (Sandbox Code Playgroud)
我想通过数据库中的每个数字,并countrycode从手机号码显示countrycode和使用PHP的国家
比如这样
countrycode 971 country UAE
countrycode 91 country India
countrycode 45 country Denmark
Run Code Online (Sandbox Code Playgroud)
任何人有任何建议请指导我如何做到这一点.
我试过这样,但想从数据库中检查多个移动数据
<?php
$number = "971527139011";
$countrys = array(
'1' => 'us',
'2' => 'uk',
'3' => 'de',
'44' => 'fi',
'123' => 'no',
'971' =>'uae',
'91' =>'india',
'92' =>'pakistan'
);
$i = 4;
$country = "";
while ($i > 0) {
if (isset($countrys[substr($number, 0, $i)])) {
$country = $countrys[substr($number, 0, $i)];
break;
} else {
$i--; …Run Code Online (Sandbox Code Playgroud) 我已经可以获取国家/地区列表,但是名称用我的语言(意大利语)显示。我需要将它们用英语显示,这就是我现在所拥有的(此代码不是我的,我是从网络上复制的)
String[] locales = Locale.getISOCountries();
ArrayList<String> list = new ArrayList<String>(500);
for (String countryCode : locales) {
Locale obj = new Locale("en", countryCode);
list.add(obj.getDisplayCountry());
}
Collections.sort(list);
country = new String[list.size()];
country = list.toArray(country);
Run Code Online (Sandbox Code Playgroud)
谢谢=)
我想在地图包中的map()中填写尼日尔的国家.我意识到,除非你指明,否则以特定字母开头的特定国家都将进行绘图,但我无法在不绘制尼日利亚情节的情况下仅绘制尼日尔.
library(maps)
#plot map of Africa
map(database = "world", regions = ".", xlim = c(-20,60), ylim = c(-40,40), wrap = FALSE, resolution = 2, type = "l", bg = par("bg"), myborder = 0.01)
# fills in Nigeria alone
map(regions = 'Nigeria',fill = TRUE, add = TRUE, col = 'green')
#fills in the countries of Niger AND Nigeria
map(regions = 'Niger',fill = TRUE, add = TRUE, col = 'gray')
Run Code Online (Sandbox Code Playgroud)
在阅读了"地图"文档并找到了这个问题后,我查看countrycode_data了"countrycode"包中的国家列表,我发现了\\bniger(?!ia)我认为属于我的问题的正则表达式.对于以"几内亚","巴布亚新几内亚"和"几内亚比绍"等相同字母或单词开头的任何其他国家,我都有同样的问题.如何仅绘制最简单的版本国家/地区名称?包国家代码中的所有代码都没有在地图上单独绘制尼日尔.
我的应用程序如何以编程方式获取设备的国家/地区代码?
当我收到传入的短信时,发件人号码始终包含国家/地区代码.但是,对于我的应用程序,我让用户手动输入他/她的电话号码,但我还需要知道国家/地区代码.
无论如何都要获取设备的国家代码和/或电话号码?
我正在尝试在 Rails 4 中制作一个应用程序。我对表单使用简单的表单,对国家/地区列表使用 country_select gem。
我有一个地址模型,其中包括这个方法:
def country_name
self.country = ISO3166::Country[country]
country.translations[I18n.locale.to_s] || country.name
end
Run Code Online (Sandbox Code Playgroud)
当我尝试保存新地址时,出现此错误:
undefined method `translations' for "Australia":String
Run Code Online (Sandbox Code Playgroud)
谁能看出这个方法定义有什么问题?
如果我将视图更改为:
<% if @profile.addresses.any? %>
<%= @profile.addresses.first.country.titlecase %>
<% else %>
<span class="profileeditlink">
<%= link_to "Add your location", new_address_path %>
</span>
<% end %>
Run Code Online (Sandbox Code Playgroud)
然后记录显示 - 但显示为 AU 而不是澳大利亚(这是地址模型中提供的方法)。
地址表:
create_table "addresses", force: :cascade do |t|
t.string "unit"
t.string "building"
t.string "street_number"
t.string "street"
t.string "city"
t.string "region"
t.string "zip"
t.string "country"
t.boolean "main_address"
t.boolean "project_offsite"
t.string …Run Code Online (Sandbox Code Playgroud) 我是 Java Android 新手。
我想在区域设置中使用国家/地区代码(参考ISO 3166-1 数字)获取国家/地区名称(字符串)
试图做这样的事情(其中 [...].getCountry() 返回 int 826):
Locale countryName = new Locale("", String.valueOf(profile.getPersonnalInformation().getAddress().getCountry()));
Run Code Online (Sandbox Code Playgroud)
并使用此获取国家/地区名称: countryName.getDisplayCountry()
它通常应该返回“英国”,但不幸的是我有 826。
我怎样才能做到这一点 ?
在此先感谢您的帮助,
I am using the country code picker library for user to select a country.
I stored the selected items with country name (i.e.: Singapore).
Now I want to convert the country name into ISO Alpha 2 country code (i.e.: sg).
I am using the Locale but it was not working, what am i missing?
public String getCountryCodeFromName(String countryName){
Locale locale = new Locale("",countryName);
String countryCode = locale.getCountry().toLowerCase();
return countryCode;
}
Run Code Online (Sandbox Code Playgroud) 我希望用户从下拉列表中选择他/她的国家/地区,然后我想在文本字段中显示国家/地区代码,以便用户输入他/她的号码.
这是包含电话号码的国家/地区列表:
<select name="country">
<option value="">Country...</option>
<option value="Afghanistan">Afghanistan</option>
<option value="Albania">Albania</option>
.
.
ETC till
<option value="Zimbabwe">Zimbabwe</option>
</select>
<label for="phone">Phone Number</label><
<input id="phone" name="phone" placeholder="user's number " required="" type="number">
Run Code Online (Sandbox Code Playgroud)
例如,当用户选择沙特阿拉伯时,我希望文本字段显示为966
我考虑将国家/地区代码作为选项中的值
country-codes ×12
android ×3
locale ×3
php ×3
country ×2
asp.net ×1
c# ×1
currency ×1
geo ×1
html ×1
html5 ×1
java ×1
javascript ×1
maps ×1
phone-number ×1
r ×1
ruby ×1
simple-form ×1