{"id":54090,"date":"2021-06-18T10:13:25","date_gmt":"2021-06-18T01:13:25","guid":{"rendered":"https:\/\/learningbox.online\/?p=54090"},"modified":"2021-06-21T08:57:56","modified_gmt":"2021-06-20T23:57:56","slug":"blog_csv-bom-utf8","status":"publish","type":"post","link":"https:\/\/learningbox.online\/en\/column\/blog_csv-bom-utf8\/","title":{"rendered":"CSV and Character Encoding - Avoid Character Garbling with utf8 with BOM"},"content":{"rendered":"<p class=\"wp-block-paragraph\">I am the representative, Nishimura! It's been a while since I wrote a blog.<br>To avoid garbled text in Excel, I added a BOM.<\/p>\n\n\n\n<div id=\"toc\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading is-style-heading__l\">learningBOX is an LMS with multilingual support<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Our e-learning system, learningBOX, is a multilingual LMS. learningBOX's UI is currently only available in Japanese and English, but the data of teaching materials and learners' answers are flexible enough to support not only Japanese and English, but also Chinese, Korean, Vietnamese, and other languages around the world. However, the data of teaching materials and learners' answers can be flexibly supported not only in Japanese and English but also in Chinese, Korean, Vietnamese and other languages around the world.<br>In fact, teaching materials created in each country's language are used in training programs for foreigners.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/learningbox.online\/wp-content\/uploads\/2020\/07\/english_main.jpg\" alt=\"Multilingual support - e-learning\" class=\"wp-image-37622\"\/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading is-style-heading__m\">Multilingual support in CSV was incomplete.<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Despite the claim of multilingual support, there was a deficiency in the CSV support. In the currently released version (2.14.28), CSV encoding is fixed to Shift_JIS (Windows-31J).<br>Therefore, all characters except Japanese, English, and some Chinese and Latin characters will be garbled.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1182\" height=\"433\" src=\"https:\/\/learningbox.online\/wp-content\/uploads\/2021\/06\/660bfde7176f8802ae7d80b8324b179d.png\" alt=\"CSV - garbled\" class=\"wp-image-54193\" srcset=\"https:\/\/learningbox.online\/wp-content\/uploads\/2021\/06\/660bfde7176f8802ae7d80b8324b179d.png 1182w, https:\/\/learningbox.online\/wp-content\/uploads\/2021\/06\/660bfde7176f8802ae7d80b8324b179d-300x110.png 300w, https:\/\/learningbox.online\/wp-content\/uploads\/2021\/06\/660bfde7176f8802ae7d80b8324b179d-1024x375.png 1024w, https:\/\/learningbox.online\/wp-content\/uploads\/2021\/06\/660bfde7176f8802ae7d80b8324b179d-768x281.png 768w, https:\/\/learningbox.online\/wp-content\/uploads\/2021\/06\/660bfde7176f8802ae7d80b8324b179d-16x6.png 16w\" sizes=\"auto, (max-width: 1182px) 100vw, 1182px\" \/><\/figure>\n<\/div>\n\n\n<a class=\"for_mokuji\" href=\"#toc\">Back to Contents<\/a>\n\n\n\n<h2 class=\"wp-block-heading is-style-heading__l\">implemented to be able to choose UTF-8<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"857\" height=\"369\" src=\"https:\/\/learningbox.online\/wp-content\/uploads\/2021\/06\/2021-06-17_16-33-14.png\" alt=\"Garbled text - e-learning\" class=\"wp-image-54195\" srcset=\"https:\/\/learningbox.online\/wp-content\/uploads\/2021\/06\/2021-06-17_16-33-14.png 857w, https:\/\/learningbox.online\/wp-content\/uploads\/2021\/06\/2021-06-17_16-33-14-300x129.png 300w, https:\/\/learningbox.online\/wp-content\/uploads\/2021\/06\/2021-06-17_16-33-14-768x331.png 768w, https:\/\/learningbox.online\/wp-content\/uploads\/2021\/06\/2021-06-17_16-33-14-16x7.png 16w\" sizes=\"auto, (max-width: 857px) 100vw, 857px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">There was a proposal to switch the character encoding of CSV output from learningBOX to UTF-8, but we decided that the impact on users would be too great if we suddenly changed the specification, so we made it possible to choose between UTF-8 and Shift_JIS for the character encoding of CSV. (Default is Shift_JIS)<\/p>\n\n\n\n<a class=\"for_mokuji\" href=\"#toc\">Back to Contents<\/a>\n\n\n\n<h2 class=\"wp-block-heading is-style-heading__l\">BOM is added to prevent garbled characters in Excel<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When I open a UTF-8 CSV without BOM in Excel, the characters are garbled. BOM stands for \"Byte Order Mark\" and indicates that the character code of the file is \"UTF-8\".<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Therefore, by using UTF-8 with BOM, you can now open the file in Excel without garbling the characters.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A long time ago, it was common to avoid garbled characters by making it in UTF-16LE, but relatively recent Excel is now better utf8 with BOM. In addition, the character code of the Web world is becoming unified into utf8, considering the ease of handling outside of Excel, I decided to utf8 instead of UTF-16LE.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Reference sites:.<a href=\"https:\/\/qiita.com\/mashiro\/items\/0d0b9bbb0f4a6cca620c\" target=\"_blank\" rel=\"noreferrer noopener\">How to output Unicode csv that opens correctly in both Win and Mac Excel<\/a><\/p>\n\n\n\n<a class=\"for_mokuji\" href=\"#toc\">Back to Contents<\/a>\n\n\n\n<h2 class=\"wp-block-heading is-style-heading__l\">How to add a BOM in PHP<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The entity of the BOM is 3 bytes of data and is expressed as \"\\xEF\\xBB\\xBF\\xBF\". In the case of PHP, the BOM can be added by doing the following<\/p>\n\n\n\n<div class=\"frame-gray\">\n<p class=\"wp-block-paragraph\"><code><strong>$csv = \"\\xEF\\xBB\\xBF\".$csv;<\/strong><\/code><\/p>\n<\/div>\n\n\n\n<a class=\"for_mokuji\" href=\"#toc\">Back to Contents<\/a>\n\n\n\n<h2 class=\"wp-block-heading is-style-heading__l\">September<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Depending on the results of the verification, it is expected to be released in an update next week or the week after.<br>For more information on the status of the learningBOX release, please click here.<a href=\"https:\/\/learningbox.online\/en\/releasenote\/\" target=\"_blank\" rel=\"noopener\">Release Note<\/a>&nbsp;<\/p>\n\n\n\n<a class=\"for_mokuji\" href=\"#toc\">Back to Contents<\/a>\n\n\n\n<h2 class=\"wp-block-heading is-style-heading__l\">We are looking for a learningBOX developer!<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">We are looking for learningBOX developers. We have various openings for backend engineers, frontend engineers, quality assurance engineers, and project managers.<br>We are looking for development engineers mainly at our headquarters in Tatsu, but we are also actively recruiting infrastructure engineers in Tokyo, so please apply if you are interested, However, if you have experience in Linux operation or have studied Linux or networking at an infrastructure school, you may be welcome!<br>For more information about employment opportunities at learningBOX, Inc,<a href=\"https:\/\/www.wantedly.com\/companies\/learningbox\/projects\" target=\"_blank\" rel=\"noreferrer noopener\">&nbsp;here<\/a>&nbsp;<\/p>\n\n\n\n<a class=\"for_mokuji\" href=\"#toc\">Back to Contents<\/a>","protected":false},"excerpt":{"rendered":"This is Mr. Nishimura, Representative Director! It's been a while since I've written a blog, but I've added a BOM to prevent garbled characters in Excel. LearningBOX is an LMS that supports multiple languages...","protected":false},"author":5,"featured_media":78898,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"template-column.php","format":"standard","meta":{"_acf_changed":false,"content-type":"","_lmt_disableupdate":"yes","_lmt_disable":"","advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_vk_print_noindex":"","_veu_custom_css":"","_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[41],"tags":[269,272,271,178],"class_list":["post-54090","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-learningbox","tag-csv","tag-elearning-","tag-shift_jis","tag-178"],"acf":[],"modified_by":"i.hirota","jetpack_featured_media_url":"https:\/\/learningbox.online\/wp-content\/uploads\/2020\/07\/english_main.jpg","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pgWaOl-e4q","_links":{"self":[{"href":"https:\/\/learningbox.online\/en\/wp-json\/wp\/v2\/posts\/54090","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learningbox.online\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learningbox.online\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learningbox.online\/en\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/learningbox.online\/en\/wp-json\/wp\/v2\/comments?post=54090"}],"version-history":[{"count":84,"href":"https:\/\/learningbox.online\/en\/wp-json\/wp\/v2\/posts\/54090\/revisions"}],"predecessor-version":[{"id":119755,"href":"https:\/\/learningbox.online\/en\/wp-json\/wp\/v2\/posts\/54090\/revisions\/119755"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/learningbox.online\/en\/wp-json\/wp\/v2\/media\/78898"}],"wp:attachment":[{"href":"https:\/\/learningbox.online\/en\/wp-json\/wp\/v2\/media?parent=54090"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learningbox.online\/en\/wp-json\/wp\/v2\/categories?post=54090"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learningbox.online\/en\/wp-json\/wp\/v2\/tags?post=54090"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}