Byte order mark: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
(Created page with "[https://en.wikipedia.org/wiki/Byte_order_mark Byte order mark] (BOM, [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 位元組...")
 
Line 5: Line 5:
Using [https://www.w3resource.com/mysql/string-functions/mysql-hex-function.php MySQL HEX() function] "returns a string representation of a hexadecimal value of a decimal or string value specified as an argument."  
Using [https://www.w3resource.com/mysql/string-functions/mysql-hex-function.php MySQL HEX() function] "returns a string representation of a hexadecimal value of a decimal or string value specified as an argument."  


[https://drive.google.com/file/d/1TSjaK0q7f-ypxP-S_5SX18TlNvUW4yRJ/view?usp=sharing Sql file]
 
[http://sqlfiddle.com/#!9/5b46b0/1/0 Run sql on sqlfiddle.com] or Download the [https://drive.google.com/file/d/1TSjaK0q7f-ypxP-S_5SX18TlNvUW4yRJ/view?usp=sharing Sql file] directly.
<pre>
<pre>
CREATE TABLE `articles` (
CREATE TABLE `articles` (

Revision as of 13:33, 23 April 2018

Byte order mark (BOM, 位元組順序記號)

How to see Byte order mark

MySQL way

Using MySQL HEX() function "returns a string representation of a hexadecimal value of a decimal or string value specified as an argument."


Run sql on sqlfiddle.com or Download the Sql file directly.

CREATE TABLE `articles` (
  `id` varchar(50) NOT NULL,
  `notes` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `articles` (`id`, `notes`) VALUES
('1234567890', 'no BOM'),
('1234567890', 'BOM');

ALTER TABLE `articles`
  ADD UNIQUE KEY `id` (`id`) USING BTREE;

SELECT HEX(id), id, notes FROM articles;
HEX(id) id notes
31323334353637383930 1234567890 no BOM
EFBBBF31323334353637383930 1234567890 BOM

File command way

Using file (command): file filename.txt on Linux Os linux.png , macOS icon_os_mac.png [1] & Cygwin on Win Os windows.png


File content Example result returned by file command
File contains BOM UTF-8 Unicode (with BOM) text
File NOT contains BOM UTF-8 Unicode text

References