Fix garbled message text: Difference between revisions

Jump to navigation Jump to search
m
Line 6: Line 6:
# (optional) Making text wrap to window size
# (optional) Making text wrap to window size


== List of the (look like but not) garbled text and possible cause ==
List of the (look like but not) garbled text and possible cause
<table border="1" style="width: 100%; table-layout: fixed;" class="wikitable sortable">
<table border="1" style="width: 100%; table-layout: fixed;" class="wikitable sortable">
<tr>
<tr>
Line 45: Line 45:
</tr>
</tr>
</table>
</table>
Possible approaches to encode the message text:
<table border="1" style="width: 100%; table-layout: fixed;" class="wikitable sortable">
<tr>
<th style="width: 20%;"> Approach
</th>
<th style="width: 25%"> Goal
</th>
<th style="width: 20%"> Is Chinese text garbled/encoded?
</th>
<th style="width: 35%;"> Sample text before encoded or after encoded
</th>
</tr>
<tr>
<th> [https://www.w3schools.com/jsref/jsref_encodeURIComponent.asp JavaScript encodeURIComponent()] <br />↔<br /> [http://www.w3schools.com/jsref/jsref_decodeuricomponent.asp JavaScript decodeURIComponent()]<ref>[http://stackoverflow.com/questions/9901027/how-to-encode-url-contains-unicode-characters-with-php urlencode - How to Encode URL Contains Unicode Characters with PHP - Stack Overflow]</ref>
</th>
<td>  "converts characters into a format that can be transmitted over the Internet ... " Cited from [http://www.w3schools.com/tags/ref_urlencode.asp w3schools]
</td>
<td> TRUE
</td>
<td style="word-wrap: break-word;"> <ul><li>before: {{kbd | key=<nowiki>http://www.中文網址.tw/my test.asp?name=ståle&car=saab</nowiki>}} <li>after: {{kbd | key=<nowiki>http%3A%2F%2Fwww.%E4%B8%AD%E6%96%87%E7%B6%B2%E5%9D%80.tw%2Fmy%20test.asp%3Fname%3Dst%C3%A5le%26car%3Dsaab</nowiki>}} </ul>
</td>
</tr>
<tr>
<th> [http://meyerweb.com/eric/tools/dencoder/ URL Decoder/Encoder]<ref>PHP [http://php.net/manual/en/function.urlencode.php urlencode()]</ref>
</th>
<td> (same as above)
</td>
<td> TRUE
</td>
<td style="word-wrap: break-word;"> (same as above)
</td>
</tr>
<tr>
<th> [http://php.net/manual/en/function.json-encode.php PHP: json_encode]<br />↔<br />[http://php.net/manual/en/function.json-decode.php PHP: json_decode]
</th>
<td>Save array in mysql database
</td>
<td> TRUE
</td>
<td style="word-wrap: break-word;"> <ul><li>before: {{kbd | key=<nowiki>array("作者" => "馬克吐溫", "名言" => "\"To a man with a hammer, everything looks like a nail.\" He said.");</nowiki>}} <li>after: {{kbd | key=<nowiki>{"\u4f5c\u8005":"\u99ac\u514b\u5410\u6eab","\u540d\u8a00":"\"To a man with a hammer, everything looks like a nail.\" He said."}</nowiki>}}</ul>
</td>
</tr>
<tr>
<th> [http://php.net/serialize PHP: serialize] <br />↔<br /> [http://php.net/manual/en/function.unserialize.php PHP: unserialize]
</th>
<td>[http://stackoverflow.com/questions/10686333/save-array-in-mysql-database Save array in mysql database]
</td>
<td> <span style="color: #999">FALSE</span>
</td>
<td style="word-wrap: break-word;"> <ul><li>before: {{kbd | key=<nowiki>array("作者" => "馬克吐溫", "名言" => "\"To a man with a hammer, everything looks like a nail.\" He said.");</nowiki>}} <li>after: {{kbd | key=<nowiki>a:2:{s:6:"作者";s:12:"馬克吐溫";s:6:"名言";s:64:""To a man with a hammer, everything looks like a nail." He said.";}</nowiki>}}</ul>
</td>
</tr>
<tr>
<th> [http://php.net/manual/en/function.htmlentities.php PHP: htmlentities][http://www.w3schools.com/html/html_entities.asp] <br />↔<br /> [http://php.net/manual/en/function.html-entity-decode.php PHP:  html_entity_decode]
</th>
<td> Replace reserved characters e.g. double quote symbol
</td>
<td> <span style="color: #999">FALSE</span>
</td>
<td style="word-wrap: break-word;"> <ul><li>before: {{kbd | key=<nowiki>馬克吐溫名言 "To a man with a hammer, everything looks like a nail."</nowiki>}} <li>after: {{kbd | key=<nowiki>
馬克吐溫名言 &amp;quot;To a man with a hammer, everything looks like a nail.&amp;quot;</nowiki>}}</ul>
</td>
</tr>
</table>
Other functions
* [https://www.w3schools.com/js/js_json_parse.asp JSON.parse()] or [http://api.jquery.com/jquery.parsejson/ jQuery.parseJSON() | jQuery API Documentation]


=== String contains {{kbd | key=<nowiki>%2</nowiki>}} or {{kbd | key=<nowiki>%20</nowiki>}} symbols ===
=== String contains {{kbd | key=<nowiki>%2</nowiki>}} or {{kbd | key=<nowiki>%20</nowiki>}} symbols ===
Anonymous user

Navigation menu