Debian Codegraph @

buildtools/emojis.php

raw symbols SCIP
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 * @brief Emoji unicodes.
16 *
17 * @note The unicode emojis in this namespace are auto-generated from https://raw.githubusercontent.com/ArkinSolomon/discord-emoji-converter/master/emojis.json
18 *
19 * @warning If you want to use this, you have to pull the header in separately. For example:
20 * ```cpp
21 * #include <dpp/dpp.h>
22 * #include <dpp/unicode_emoji.h>
23 * ```
24 */
25 namespace unicode_emoji {
26
27 END;
28
29 /* This JSON is generated originally via the NPM package maintained by Discord themselves at https://www.npmjs.com/package/discord-emoji */
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 }