Fix garbled message text: Difference between revisions

Jump to navigation Jump to search
Line 90: Line 90:
</tr>
</tr>
<tr>
<tr>
<td>Downloaded Json or JavaScript file which its content contains {{kbd | key=<nowiki>\u</nowiki>}} symbols</td>
<td>Downloaded Json or JavaScript file which its content contains {{kbd | key=<nowiki>\u</nowiki>}} or {{kbd | key=<nowiki>\U</nowiki>}} symbols</td>
<td style="word-wrap: break-word;">{{kbd | key=<nowiki>\u4f5c</nowiki>}}</td>
<td style="word-wrap: break-word;">{{kbd | key=<nowiki>\u8c61</nowiki>}} or {{kbd | key=<nowiki>\U0001f418</nowiki>}}</td>
<td>(1) 16-bit or 32-bit hex value (2) "JSON representation of the supplied value"<ref>[http://php.net/manual/en/function.json-encode.php PHP: json_encode - Manual]</ref><ref>[http://www.faqs.org/rfcs/rfc7159.html RFC 7159: The JavaScript Object Notation (JSON) Data Interchange Format]</ref></td>
<td>(1) 16-bit or 32-bit hex value (2) "JSON representation of the supplied value"<ref>[http://php.net/manual/en/function.json-encode.php PHP: json_encode - Manual]</ref><ref>[http://www.faqs.org/rfcs/rfc7159.html RFC 7159: The JavaScript Object Notation (JSON) Data Interchange Format]</ref></td>
<td>JSON decode ↔ JSON eocode</td>
<td>JSON decode ↔ JSON eocode</td>
</tr>
<tr>
<td>String starting from {{kbd | key=<nowiki>0x</nowiki>}} symbols</td>
<td style="word-wrap: break-word;">{{kbd | key=<nowiki>0x8c61</nowiki>}}</td>
<td>hexadecimal string<ref>[https://www.programiz.com/python-programming/methods/built-in/hex Python hex() - Python Standard Library]</ref></td>
<td></td>
</tr>
</tr>
<tr>
<tr>
Line 103: Line 109:
</table>
</table>


=== text starting from \u symbol ===
=== string starting from \u or \U symbol ===
Using PHP. Type is string
Using PHP. Type is string
<pre>
<pre>
Line 139: Line 145:
</pre>
</pre>


=== text starting from \x symbol ===
=== string starting from 0x symbol ===
Using Python [https://www.w3schools.com/python/ref_func_chr.asp chr() Function] ↔ [https://www.programiz.com/python-programming/methods/built-in/hex hex() function]
<pre>
int('0x8c61', 16)
# print 35937 -- "An integer representing a valid Unicode code point" cited from w3schools
chr(int('0x8c61', 16))
# print '象' -- "returns the character that represents the specified unicode." cited from w3schools
hex(ord('象'))
# print '0x8c61' -- "converts an integer number to the corresponding hexadecimal string." cited from programiz.com
 
chr(int('0x1f418', 16))
# print '🐘'
hex(ord('🐘'))
# print '0x1f418'
</pre>
 
=== string starting from \x symbol ===
Using Python<ref>[https://docs.python.org/3/library/stdtypes.html#bytes.decode bytes.decode()]</ref><ref>[https://docs.python.org/3/library/stdtypes.html#str.encode str.encode()]</ref><ref>[https://stackoverflow.com/questions/33294213/how-to-decode-unicode-in-a-chinese-text python - How to decode unicode in a Chinese text - Stack Overflow]</ref>
Using Python<ref>[https://docs.python.org/3/library/stdtypes.html#bytes.decode bytes.decode()]</ref><ref>[https://docs.python.org/3/library/stdtypes.html#str.encode str.encode()]</ref><ref>[https://stackoverflow.com/questions/33294213/how-to-decode-unicode-in-a-chinese-text python - How to decode unicode in a Chinese text - Stack Overflow]</ref>
<pre>
<pre>

Navigation menu