15,050
edits
| (2 intermediate revisions by the same user not shown) | |||
| Line 44: | Line 44: | ||
<td>Unicode HTML code. "Unicode number in decimal, hex or octal"<ref>[http://www.amp-what.com/help.html &what Help]</ref></td> | <td>Unicode HTML code. "Unicode number in decimal, hex or octal"<ref>[http://www.amp-what.com/help.html &what Help]</ref></td> | ||
<td>[https://www.php.net/manual/en/function.html-entity-decode.php PHP: html_entity_decode] ↔ (See the following section to understand how to encode)</td> | <td>[https://www.php.net/manual/en/function.html-entity-decode.php PHP: html_entity_decode] ↔ (See the following section to understand how to encode)</td> | ||
</tr> | |||
<tr> | |||
<td>HTML source code starting from {{kbd | key=<nowiki>& ... ;</nowiki>}} symbols</td> | |||
<td style="word-wrap: break-word;">{{kbd | key=<nowiki>& a m p ;</nowiki>}} (without whitespace) is {{kbd | key=<nowiki>&</nowiki>}}</td> | |||
<td>"all characters which have HTML character entity equivalents are translated into these entities"<ref>[https://www.php.net/manual/en/function.htmlentities.php PHP: htmlentities - Manual]</ref></td> | |||
<td>[https://www.php.net/manual/en/function.htmlspecialchars-decode.php PHP: htmlspecialchars_decode] ↔ [https://www.php.net/manual/en/function.htmlentities.php PHP: htmlentities]</td> | |||
</tr> | </tr> | ||
</table> | </table> | ||
| Line 142: | Line 148: | ||
echo "encoded string: " . json_encode("🐘") . PHP_EOL; // print "\ud83d\udc18" | echo "encoded string: " . json_encode("🐘") . PHP_EOL; // print "\ud83d\udc18" | ||
</pre> | </pre> | ||
when using the heredoc syntax (<<<EOT ... EOT;), it's possible that unnecessary whitespace or hidden characters at the beginning or end of the block might cause json_decode to fail in parsing the string correctly. Direct assignment avoids potential whitespace or format issues from heredoc. | |||
<pre> | |||
$encoded = '"\u8c61"'; | |||
echo "decoded string: " . json_decode($encoded, true) . PHP_EOL; // print 象 | |||
echo "encoded string: " . json_encode("象") . PHP_EOL; // print "\u8c61" | |||
</pre> | |||
Using PHP v. 7.0 [https://wiki.php.net/rfc/unicode_escape Unicode Codepoint Escape Syntax]<ref>[https://secure.php.net/manual/en/migration70.new-features.php#migration70.new-features.unicode-codepoint-escape-syntax PHP: New features - Manual]</ref> | Using PHP v. 7.0 [https://wiki.php.net/rfc/unicode_escape Unicode Codepoint Escape Syntax]<ref>[https://secure.php.net/manual/en/migration70.new-features.php#migration70.new-features.unicode-codepoint-escape-syntax PHP: New features - Manual]</ref> | ||
| Line 316: | Line 330: | ||
* [http://en.wikipedia.org/wiki/Character_encoding Character encoding - Wikipedia, the free encyclopedia] | * [http://en.wikipedia.org/wiki/Character_encoding Character encoding - Wikipedia, the free encyclopedia] | ||
* [https://pjchender.blogspot.com/2018/06/guide-unicode-javascript.html (Guide) 瞭解網頁中看不懂的編碼:Unicode 在 JavaScript 中的使用 ~ PJCHENder 那些沒告訴你的小細節] | * [https://pjchender.blogspot.com/2018/06/guide-unicode-javascript.html (Guide) 瞭解網頁中看不懂的編碼:Unicode 在 JavaScript 中的使用 ~ PJCHENder 那些沒告訴你的小細節] | ||
* [https://www.multiutil.com/base64-to-text-converter/ Base64 to Text Converter] | |||
* [https://www.multiutil.com/gzip-to-text-decompress/ Gzip to Text Decompress using gzip, deflate and brotli algoithms] | |||
* [[URL Encoding]] | * [[URL Encoding]] | ||
Unicode table | Unicode table | ||