Usage Scenario: PHP as the server-side receive app interface data, due to MySQL format problem caused by no way to directly save emoticons package
The solution is to convert the expression to Base64 can be seen in the format, due to the length of the conversion is too large, replace it with the corresponding characters saved into the database
<?php class emoji{/** * Turns the expression to the corresponding representative string * @param string $content */ public static function Emojiencode ($content = ") {if (! $content) {return $content; } $content = Json_encode ($content); $emoji = requrie_once (' emoji.php '); $content = Str_replace (Array_keys ($emoji [' Regenencode ']), $emoji [' Regenencode '], $content); $content = Json_decode ($content, true); return $content; /** * Convert the corresponding string into an expression * @param string $content */public static function Emojidecode ($content = ") { if (! $content) {return $content; } $content = Json_encode ($content); $emoji = requrie_once (' emoji.php '); $content = Str_replace (Array_keys ($emoji [' Regendecode ']), $emoji [' Regendecode '], $content); $content = Json_decode ($content, true); return $content; }}