/* Emacs admin/unidata/emoji-zwj-sequences.txt 向け 家族絵文字パターン生成機 $ ldc2 -O2 gen_family_emoji.d $ ./gen_family_emoji 4 1 > file.txt */ import std.stdio; import std.string; import std.conv; import std.math; import std.bigint; import std.algorithm; import std.container; import std.range; import std.array; struct attr{ string name; string skin; string cp; this(string name, string skin, string codepoint){ this.name=name; this.skin=skin; this.cp=codepoint; } }; int add_family(string[] fb, string[][] cl, attr[string] chtxt, int level, int maxlevel) { int locallv = level<2 ? level : 2; if( level>maxlevel ) return 0; foreach(ch; cl[locallv]){ string[] cpbuf; if( ch=="" ) cpbuf=fb.dup; else cpbuf=fb.dup ~ ch; if( level>maxlevel || ch=="" ){ string[] codetxt; string[] ftxt1; string[] ftxt2; foreach(c; cpbuf){ codetxt ~= chtxt[c].cp; ftxt1 ~= chtxt[c].name; ftxt2 ~= chtxt[c].skin; } string ftxt2join = ftxt2.join(""); writef("%-64s ; RGI_Emoji_ZWJ_Sequence ; family: %-120s #E4.0 [1] (%s)\n", codetxt.join(" 200D "), ftxt2join!="" ? ftxt1.join(",") ~ ", " ~ ftxt2.join(",") : ftxt1.join(","), cpbuf.join("‍")); continue; } add_family(cpbuf,cl,chtxt,level+1,maxlevel); } return 0; } int main(string[] args) { int maxdepth = 3; int select = 0; if( args.length>=2 ){ maxdepth = args[1].to!int(); if( maxdepth<2 ){ writef("Please specify a value of 2 or more.\n"); return 0; } } if( args.length>=3 ){ select = args[2].to!int(); } string[][] chlist; if( select==0 ){ // 肌パターン無し chlist.length=3; chlist[0]=["👨", "👩"]; chlist[1]=["👨", "👩", "👦","👧"]; chlist[2]=["👦", "👧", ""]; }else{ // 肌パターン有り chlist.length=3; chlist[0]=[//"🧑", "🧑🏻", "🧑🏼", "🧑🏽", "🧑🏾", "🧑🏿", "👨", "👨🏻", "👨🏼", "👨🏽", "👨🏾", "👨🏿", "👩", "👩🏻", "👩🏼", "👩🏽", "👩🏾", "👩🏿" ]; chlist[1]=[//"🧑", "🧑🏻", "🧑🏼", "🧑🏽", "🧑🏾", "🧑🏿", "👨", "👨🏻", "👨🏼", "👨🏽", "👨🏾", "👨🏿", "👩", "👩🏻", "👩🏼", "👩🏽", "👩🏾", "👩🏿", //"🧒", "🧒🏻", "🧒🏼", "🧒🏽", "🧒🏾", "🧒🏿", "👦", "👦🏻", "👦🏼", "👦🏽", "👦🏾", "👦🏿", "👧", "👧🏻", "👧🏼", "👧🏽", "👧🏾", "👧🏿" ]; chlist[2]=[//"🧒", "🧒🏻", "🧒🏼", "🧒🏽", "🧒🏾", "🧒🏿", "👦", "👦🏻", "👦🏼", "👦🏽", "👦🏾", "👦🏿", "👧", "👧🏻", "👧🏼", "👧🏽", "👧🏾", "👧🏿", ""]; } attr[string] chtxt = ["🧑" : attr("person", "", "1F9D1"), "🧑🏻" : attr("person", "light skin tone", "1F9D1 1F3FB"), "🧑🏼" : attr("person", "medium-light skin tone", "1F9D1 1F3FC"), "🧑🏽" : attr("person", "medium skin tone", "1F9D1 1F3FD"), "🧑🏾" : attr("person", "medium-dark skin tone", "1F9D1 1F3FE"), "🧑🏿" : attr("person", "dark skin tone", "1F9D1 1F3FF"), "👨" : attr("man", "", "1F468"), "👨🏻" : attr("man", "light skin tone", "1F468 1F3FB"), "👨🏼" : attr("man", "medium-light skin tone", "1F468 1F3FC"), "👨🏽" : attr("man", "medium skin tone", "1F468 1F3FD"), "👨🏾" : attr("man", "medium-dark skin tone", "1F468 1F3FE"), "👨🏿" : attr("man", "dark skin tone", "1F468 1F3FF"), "👩" : attr("woman", "", "1F469"), "👩🏻" : attr("woman", "light skin tone", "1F469 1F3FB"), "👩🏼" : attr("woman", "medium-light skin tone", "1F469 1F3FC"), "👩🏽" : attr("woman", "medium skin tone", "1F469 1F3FD"), "👩🏾" : attr("woman", "medium-dark skin tone", "1F469 1F3FE"), "👩🏿" : attr("woman", "dark skin tone", "1F469 1F3FF"), "🧒" : attr("child", "", "1F9D2"), "🧒🏻" : attr("child", "light skin tone", "1F9D2 1F3FB"), "🧒🏼" : attr("child", "medium-light skin tone", "1F9D2 1F3FC"), "🧒🏽" : attr("child", "medium skin tone", "1F9D2 1F3FD"), "🧒🏾" : attr("child", "medium-dark skin tone", "1F9D2 1F3FE"), "🧒🏿" : attr("child", "dark skin tone", "1F9D2 1F3FF"), "👦" : attr("boy", "", "1F466"), "👦🏻" : attr("boy", "light skin tone", "1F466 1F3FB"), "👦🏼" : attr("boy", "medium-light skin tone", "1F466 1F3FC"), "👦🏽" : attr("boy", "medium skin tone", "1F466 1F3FD"), "👦🏾" : attr("boy", "medium-dark skin tone", "1F466 1F3FE"), "👦🏿" : attr("boy", "dark skin tone", "1F466 1F3FF"), "👧" : attr("girl", "", "1F467"), "👧🏻" : attr("girl", "light skin tone", "1F467 1F3FB"), "👧🏼" : attr("girl", "medium-light skin tone", "1F467 1F3FC"), "👧🏽" : attr("girl", "medium skin tone", "1F467 1F3FD"), "👧🏾" : attr("girl", "medium-dark skin tone", "1F467 1F3FE"), "👧🏿" : attr("girl", "dark skin tone", "1F467 1F3FF") ]; string[] familybuf; add_family(familybuf, chlist, chtxt, 0, maxdepth); return 0; }