按国家/地区代码获取表情符号标志
有一个国家代码列表,我需要在每个代码上附加表情符号标志。有没有办法从中提取unicode或查找国家代码的表情符号?
这个npm示例对于我的目标看起来很相似(但使用十六进制作为输入),https://github.com/thekelvinliu/country-code-emoji/blob/master/src/index.js
有一个国家代码列表,我需要在每个代码上附加表情符号标志。有没有办法从中提取unicode或查找国家代码的表情符号?
这个npm示例对于我的目标看起来很相似(但使用十六进制作为输入),https://github.com/thekelvinliu/country-code-emoji/blob/master/src/index.js
这个代码片段对我有用。只需替换为您喜欢的任何有效的国家/地区代码(基于区域指示符号字母),它将创建一个包含该国家/地区标志表情符号的字符串。(参考资料"US"
flag
)
int flagOffset = 0x1F1E6;
int asciiOffset = 0x41;
String country = "US";
int firstChar = Character.codePointAt(country, 0) - asciiOffset + flagOffset;
int secondChar = Character.codePointAt(country, 1) - asciiOffset + flagOffset;
String flag = new String(Character.toChars(firstChar))
+ new String(Character.toChars(secondChar));
function getFlags($code){
$code = strtoupper($code);
if($code == 'AD') return '