| 1 |
<?php |
| 2 |
|
| 3 |
ini_set("default_charset", "UTF-8"); |
| 4 |
|
| 5 |
echo "-- Autogenrating include/dpp/unicode_emoji.h\n"; |
| 6 |
|
| 7 |
$url = "https://raw.githubusercontent.com/ArkinSolomon/discord-emoji-converter/master/emojis.json"; |
| 8 |
|
| 9 |
$header = <<<END |
| 10 |
#pragma once |
| 11 |
|
| 12 |
namespace dpp { |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
namespace unicode_emoji { |
| 26 |
|
| 27 |
END; |
| 28 |
|
| 29 |
|
| 30 |
$emojis = json_decode(file_get_contents($url)); |
| 31 |
if ($emojis) { |
| 32 |
foreach ($emojis as $name=>$code) { |
| 33 |
if (preg_match("/^\d+/", $name)) { |
| 34 |
$name = "_" . $name; |
| 35 |
} |
| 36 |
$name = str_replace("-", "minus", $name); |
| 37 |
$name = str_replace("+", "plus", $name); |
| 38 |
$name = str_replace("ñ", "n", $name); |
| 39 |
if ($name == "new") { |
| 40 |
$name = "_new"; |
| 41 |
} |
| 42 |
$header .= " inline constexpr const char " .$name . "[] = \"$code\";\n"; |
| 43 |
} |
| 44 |
$header .= "}\n};\n"; |
| 45 |
file_put_contents("include/dpp/unicode_emoji.h", $header); |
| 46 |
} |