{"id":12081,"date":"2017-11-02T14:21:37","date_gmt":"2017-11-02T19:21:37","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=12081"},"modified":"2017-11-02T14:21:37","modified_gmt":"2017-11-02T19:21:37","slug":"unix-check-file-is-utf-8-encoding-or-not","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=12081","title":{"rendered":"Unix: Check File is UTF-8 Encoding or Not"},"content":{"rendered":"<div class='toc wptoc'>\n<h2>Contents<\/h2>\n<ol class='toc-odd level-1'>\n\t<li>\n\t\t<a href=\"#Example\">Example<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#References\">References<\/a>\n\t<\/li>\n<\/ol>\n<\/ol>\n<\/div>\n<div class='wptoc-end'>&nbsp;<\/div>\n<pre lang=\"bash\">\r\niconv -f utf-8 -t ucs-4 < myfile >\/dev\/null\r\n# No error means utf-8 encoding\r\n# Error means NOT utf-8 encoding\r\n<\/pre>\n<span id=\"Example\"><h2>Example<\/h2><\/span>\n<pre lang=\"bash\">\r\n$ iconv -f utf-8 -t ucs-4 < utf8_file >\/dev\/null\r\n$ iconv -f utf-8 -t ucs-4 < non_utf8_file >\/dev\/null\r\niconv: conversion error\r\nConversion error detected while processing stdin.\r\n<\/pre>\n<span id=\"References\"><h2>References<\/h2><\/span>\n<p>* <a href=\"https:\/\/stackoverflow.com\/questions\/11018967\/how-can-i-be-sure-of-the-file-encoding\">How can I be sure of the file encoding?<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>iconv -f utf-8 -t ucs-4 < myfile >\/dev\/null # No error means utf-8 encoding # Error means NOT utf-8 encoding Example $ iconv -f utf-8 -t ucs-4 < utf8_file >\/dev\/null $ iconv -f utf-8 -t ucs-4 < non_utf8_file >\/dev\/null iconv: &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=12081\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-12081","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-38R","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/12081","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12081"}],"version-history":[{"count":3,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/12081\/revisions"}],"predecessor-version":[{"id":12084,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/12081\/revisions\/12084"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12081"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12081"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12081"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}