# Translate English Characters to the Emoji Flag Alphabet

## Introduction

Emoji use a particular alphabet for their national flags, which allows one to put two symbols together to create the appropriate flag.

🇦🇧🇨🇩🇪🇫🇬🇭🇮🇯🇰🇱🇲🇳🇴🇵🇶🇷🇸🇹🇺🇻🇼🇽🇾🇿

Your challenge, is to transform any uppercase letter into the appropriate Flag Identifier.

This may be much harder for languages that do not innately handle Unicode. Each symbol is exactly 4 UTF-8 Bytes.

Given an input as one or more letters, output the same, with all letters replaced with their flag combinations.

Winner is the answer with the least Bytes, giving the tiebreaker to first answer posted.

## Input / Output

Input and Output may use any standard method. Letters in the input may optionally only support one case, Upper or Lower. Please specify in your answer what case your solution supports.

Your output may, intentionally or otherwise, output flag emoji instead of letter pairs.

## Test Cases

FR 🇫🇷

Hello, World! 🇭🇪🇱🇱🇴, 🇼🇴🇷🇱🇩!

## Rules

• Standard Loopholes Apply
• Standard Input Output allowed
• This is , however, All the Emoji Letters as provided above can be counted for a single byte each, instead of four. Least Bytes wins!
• Test case number two transforms both cases, do we have to do this? – Maltysen Oct 25 '16 at 2:23
• As stated, it's not required. It's just to show what would happen if supported. – ATaco Oct 25 '16 at 2:24
• bytes should be counted, someone can just pack data into dense Chinese characters and win. – noɥʇʎԀʎzɐɹƆ Oct 25 '16 at 2:40
• I'll change it to count bytes, but let the flag letter emoji count as only one byte, to keep with the initial intention. – ATaco Oct 25 '16 at 2:43
• Is this a duplicate of this? – Angs Oct 25 '16 at 9:57

# Retina - 9 7 bytes

Supports uppercase.

I don't really know retina, so I'm not sure the question mark diamonds show up because of TIO limitations or because I did something wrong, if its the latter, please leave a comment.

TL🇦-🇿

• The obvious solution sometimes is also the best. – ATaco Oct 26 '16 at 22:33

# Pyth - 18 16 bytes

Supports lowercase.

XzGsCMrF+BC\🇦26

• Doesn't convert FR for me on online link? – Downgoat Oct 25 '16 at 2:46
• @Downgoat FR is all uppercase, and this answer only supports lowercase – Trebuchette Oct 25 '16 at 3:00
• @ATaco did not see that will be golfing that – Maltysen Oct 25 '16 at 3:07

# Lua 5.3, 76 bytes

Lua 5.3 newly has a UTF-8 manipulation library, which is useful in this case.

Lowercase only

print(arg[1]:gsub("%l",function(c)return utf8.char(c:byte()+127365)end).."")


# Jelly, 13 bytes

e€ØA×“¢®Ƒ’+OỌ


Supports only uppercase letters.

Try it online!

## Explanation

e€ØA×“¢®Ƒ’+OỌ  Input: string S
e€             Test if each char in S is an element of
ØA             the uppercase alphabet 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
×          Multiply by
“¢®Ƒ’       The codepoints of '¢®Ƒ' as a base 250 integer
This forms 127397
O     The codepoints of each char in S
Ọ  Convert back to char from codepoints
Return and print implicitly


## JavaScript (ES6), 70 bytes

f=
s=>s.replace(/[A-Z]/g,c=>String.fromCodePoint(c.codePointAt()+127397))
;
<input oninput=o.textContent=f(this.value)><div id=o>

Accepts upper case only. Mixed case version for 73 bytes:

f=
s=>s.replace(/[A-Z]/gi,c=>String.fromCodePoint(c.codePointAt()+5|127392))
;
<input oninput=o.textContent=f(this.value)><div id=o>

# PHP, 101 Bytes

supports both replace 64 with 96 to support only lowercase. input only ascii characters allowed

foreach(str_split($argv[1])as$c)echo($o=ord($c))>64&&$o%32<27?hex2bin("f09f87".dechex($o%32+165)):$c;  PHP, 112 Bytes supports both remove i as modifier in the regex to support only lowercase <?=preg_replace_callback("#[a-z]#i",function($t){return hex2bin("f09f87".dechex(ord($t[0])%32+165));},$argv[1]);


first version 205 Bytes

<?=preg_replace_callback("#[a-z]#i",function($t){return substr("🇦🇧🇨🇩🇪🇫🇬🇭🇮🇯🇰🇱🇲🇳🇴🇵🇶🇷🇸🇹🇺🇻🇼🇽🇾🇿",(ord($t[0])%32-1)*4,4);},\$argv[1]);


The version with mb_substr is one Byte longer

# Python 3, 68 bytes

lambda s:''.join(chr(x+127397*(64<x<91))for x in map(ord,s.upper()))


Usage (when assigned to f):

print(f("Hello, World!"))
print(f("A B C - X Y Z"))


# Scala, 75 bytes

(s:String)=>s.flatMap(c=>if(c.isLetter)Seq(55356,c+56741)else Seq(c))


Explanation:

(s:String)=>             //define an anonymous function taking a string
s.flatMap(c=>            //map each char...
if(c.isLetter)           //if it's a letter
Seq(55356,c+56741)       //...to a sequence of 55356 and c+56741, this is the target char in UTF16 encoding as a surrogate pair
else                     //else
Seq(c)                   //..to a sequence of c
)                        //and flatten


Only works for uppercase. This returns a the output as sequence of integers in UTF16.