Byte order mark: Difference between revisions
Jump to navigation
Jump to search
→How to see Byte order mark
m (Text replacement - "Category:Text file processing" to "Category:String manipulation") |
|||
| (2 intermediate revisions by the same user not shown) | |||
| Line 82: | Line 82: | ||
* {{kbd | key=<nowiki>=CODE(A1)</nowiki>}} returns {{kbd | key=95}} on Excel 2016 of {{Mac}} | * {{kbd | key=<nowiki>=CODE(A1)</nowiki>}} returns {{kbd | key=95}} on Excel 2016 of {{Mac}} | ||
* {{kbd | key=<nowiki>=CODE(A1)</nowiki>}} returns {{kbd | key=65279}} or other numeric value e.g. {{kbd | key=28201}} on Google sheet | * {{kbd | key=<nowiki>=CODE(A1)</nowiki>}} returns {{kbd | key=65279}} or other numeric value e.g. {{kbd | key=28201}} on Google sheet | ||
=== BASH command === | |||
Check if a UTF-8 encoded file contains a BOM. The first line result of {{kbd | key=hexdump}} mentioning ef bb bf indicates it contains a BOM | |||
<pre> | |||
% hexdump -n 3 -C filename | |||
00000000 ef bb bf |...| | |||
00000003 | |||
</pre> | |||
=== File command === | === File command === | ||
| Line 88: | Line 98: | ||
=== Hex editor === | === Hex editor === | ||
Using Hext editor to open the text file. [https://zh.wikipedia.org/wiki/%E4%BD%8D%E5%85%83%E7%B5%84%E9%A0%86%E5%BA%8F%E8%A8%98%E8%99%9F 位元組順序記號 - 維基百科,自由的百科全書] | Using Hext editor to open the text file. [https://zh.wikipedia.org/wiki/%E4%BD%8D%E5%85%83%E7%B5%84%E9%A0%86%E5%BA%8F%E8%A8%98%E8%99%9F 位元組順序記號 - 維基百科,自由的百科全書] | ||
== How to remove Byte order mark == | |||
PHP | |||
* [https://stackoverflow.com/questions/10290849/how-to-remove-multiple-utf-8-bom-sequences php - How to remove multiple UTF-8 BOM sequences - Stack Overflow] | |||
* [https://stackoverflow.com/questions/22600235/remove-or-match-a-unicode-zero-width-space-php replace - Remove or match a Unicode Zero Width Space PHP - Stack Overflow] | |||
<pre> | |||
// 原始資料:程式碼編輯器會顯示為 ZWNBSP,但是一般編輯器試看不到 | |||
$text = "\xef\xbb\xbf" . "單位名稱"; | |||
// 移除 BOM | |||
$text = preg_replace('/[\x{200B}-\x{200D}\x{FEFF}]/u', '', $text); | |||
</pre> | |||
== References == | == References == | ||