File: emojis.php

package info (click to toggle)
dpp 10.1.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,972 kB
  • sloc: cpp: 48,486; ansic: 7,991; php: 1,293; python: 80; sh: 60; makefile: 15
file content (46 lines) | stat: -rw-r--r-- 1,327 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php

ini_set("default_charset", "UTF-8");

echo "-- Autogenrating include/dpp/unicode_emoji.h\n";

$url = "https://raw.githubusercontent.com/ArkinSolomon/discord-emoji-converter/master/emojis.json";

$header = <<<END
#pragma once

namespace dpp {

/**
 * @brief Emoji unicodes.
 *
 * @note The unicode emojis in this namespace are auto-generated from https://raw.githubusercontent.com/ArkinSolomon/discord-emoji-converter/master/emojis.json
 *
 * @warning If you want to use this, you have to pull the header in separately. For example:
 * ```cpp
 * #include <dpp/dpp.h>
 * #include <dpp/unicode_emoji.h>
 * ```
 */
namespace unicode_emoji {

END;

/* This JSON is generated originally via the NPM package maintained by Discord themselves at https://www.npmjs.com/package/discord-emoji */
$emojis = json_decode(file_get_contents($url));
if ($emojis) {
    foreach ($emojis as $name=>$code) {
        if (preg_match("/^\d+/", $name)) {
            $name = "_" . $name;
        }
	$name = str_replace("-", "minus", $name);
	$name = str_replace("+", "plus", $name);
	$name = str_replace("ñ", "n", $name);
	if ($name == "new") {
		$name = "_new";
	}
        $header .= "	inline constexpr const char " .$name . "[] = \"$code\";\n";
    }
    $header .= "}\n};\n";
    file_put_contents("include/dpp/unicode_emoji.h", $header);
}