{"id":1354,"date":"2016-02-16T22:53:04","date_gmt":"2016-02-16T13:53:04","guid":{"rendered":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/?p=1354"},"modified":"2016-06-11T07:53:43","modified_gmt":"2016-06-10T22:53:43","slug":"electron-iconv-lite","status":"publish","type":"post","link":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/2016\/02\/16\/electron-iconv-lite\/","title":{"rendered":"Electron\u3067\u30a8\u30c7\u30a3\u30bf\u3092\u4f5c\u308b(ACE\u4f7f\u7528)\u3000\uff5eiconv-lite\u3067Shift-JIS\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3080\uff5e"},"content":{"rendered":"<p>[ad#top-1]<br \/>\n&nbsp;<\/p>\n<p>\u524d\u56de\u3001Shift-JIS\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3060\u3089\u6587\u5b57\u5316\u3051\u3057\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002\u4ee5\u4e0b\u306e\u56f3\u306e\u901a\u308a\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1350\" src=\"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-content\/uploads\/2016\/02\/2-6.png\" alt=\"2\" width=\"630\" height=\"462\" srcset=\"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-content\/uploads\/2016\/02\/2-6.png 630w, http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-content\/uploads\/2016\/02\/2-6-400x293.png 400w\" sizes=\"auto, (max-width: 630px) 100vw, 630px\" \/><\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"UjIalNUyV9\"><p><a href=\"https:\/\/pineplanter.moo.jp\/non-it-salaryman\/2016\/02\/16\/electron-editor-read-file\/\">Electron\u3067\u30a8\u30c7\u30a3\u30bf\u3092\u4f5c\u308b(ACE\u4f7f\u7528)\u3000\uff5e\u30ed\u30fc\u30ab\u30eb\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\uff5e<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Electron\u3067\u30a8\u30c7\u30a3\u30bf\u3092\u4f5c\u308b(ACE\u4f7f\u7528)\u3000\uff5e\u30ed\u30fc\u30ab\u30eb\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\uff5e&#8221; &#8212; \u975eIT\u4f01\u696d\u306b\u52e4\u3081\u308b\u4e2d\u5e74\u30b5\u30e9\u30ea\u30fc\u30de\u30f3\u306eIT\u65e5\u8a18\" src=\"https:\/\/pineplanter.moo.jp\/non-it-salaryman\/2016\/02\/16\/electron-editor-read-file\/embed\/#?secret=5XyFBf0LQ2#?secret=UjIalNUyV9\" data-secret=\"UjIalNUyV9\" width=\"580\" height=\"327\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>\u524d\u56de\u540c\u69d8\u3001\u30a8\u30c7\u30a3\u30bf\u30e9\u30a4\u30d6\u30e9\u30ea\u30fc\u306bACE\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u4ef6\u3092Google+\u3067\u7d39\u4ecb\u3057\u305f\u3089\u3001\u89e3\u6c7a\u7b56\u3092\u6559\u3048\u3066\u3082\u3089\u3048\u307e\u3057\u305f\u3002<strong>iconv-lite<\/strong>\u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3044\u307e\u3059\u3002\u4eca\u56de\u305d\u308c\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p><strong>iconv-lite\u00a0<\/strong><br \/>\n<a href=\"https:\/\/www.npmjs.com\/package\/iconv-lite\" target=\"_blank\">https:\/\/www.npmjs.com\/package\/iconv-lite<\/a><\/p>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u7c21\u5358\u3067\u3001\u4ee5\u4e0b\u306enpm\u30b3\u30de\u30f3\u30c9\u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<div style=\"padding: 3px; background: #000000;\"><span style=\"color: #ffffff; font-family: Courier New;\">&gt; npm install iconv-lite<\/span><\/div>\n<p>&nbsp;<\/p>\n<p>\u6b21\u306b\u3001editor.js\u5185\u3067\u30d1\u30d6\u30ea\u30c3\u30af\u5ba3\u8a00\u3067\u3001<\/p>\n<p><span style=\"color: #0000ff;\">var iconv = require(&#8216;iconv-lite&#8217;);<\/span><\/p>\n<p>\u3068\u3084\u308c\u3070\u6e96\u5099OK\u3067\u3059\u3002\u3042\u3068\u306f\u4ee5\u4e0b\u306e\u901a\u308aShift-JIS\u304b\u3089UTF-8\u3078\u5909\u63db\u3057\u307e\u3059\u30028\u884c\u76ee\u304c\u305d\u306e\u51e6\u7406\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<div style=\"border: #999999 1px solid; font-family: Courier New; font-size: 11pt; height: 200px; width: 100%; overflow: scroll; padding: 0px; scrollbar-3dlight-color: #333333; scrollbar-arrow-color: #333333; scrollbar-darkshadow-color: #ffffff; scrollbar-face-color: #ddddff; scrollbar-highlight-color: #ffffff; scrollbar-shadow-color: #444444; scrollbar-track-color: #ffffff; white-space: nowrap;\">\n<table style=\"width: 100%; padding: 0px; white-space: nowrap;\" border=\"0\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td style=\"background: #eeeeee; border-style: none; font-family: Courier New; font-size: 11pt; padding-left: 10px; padding-top: 0px; padding-bottom: 0px; color: #666666; white-space: nowrap; height: 15px;\">function readFile(path) {<\/td>\n<\/tr>\n<tr>\n<td style=\"background: #ffffff; border-style: none; font-family: Courier New; font-size: 11pt; padding-left: 10px; padding-top: 0px; padding-bottom: 0px; color: #666666; white-space: nowrap; height: 15px;\">\u00a0\u00a0\u00a0fs.readFile(path, function (error, text) {<\/td>\n<\/tr>\n<tr>\n<td style=\"background: #eeeeee; border-style: none; font-family: Courier New; font-size: 11pt; padding-left: 10px; padding-top: 0px; padding-bottom: 0px; color: #666666; white-space: nowrap; height: 15px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: crimson; font-family: Courier New; font-size: 11pt;\">if<\/span> (error != <span style=\"color: crimson; font-family: Courier New; font-size: 11pt;\">null<\/span>) {<\/td>\n<\/tr>\n<tr>\n<td style=\"background: #ffffff; border-style: none; font-family: Courier New; font-size: 11pt; padding-left: 10px; padding-top: 0px; padding-bottom: 0px; color: #666666; white-space: nowrap; height: 15px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0alert(<span style=\"color: magenta; font-family: Courier New; font-size: 11pt;\">&#8216;error : &#8216;<\/span> + error);<\/td>\n<\/tr>\n<tr>\n<td style=\"background: #eeeeee; border-style: none; font-family: Courier New; font-size: 11pt; padding-left: 10px; padding-top: 0px; padding-bottom: 0px; color: #666666; white-space: nowrap; height: 15px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: crimson; font-family: Courier New; font-size: 11pt;\">return<\/span>;<\/td>\n<\/tr>\n<tr>\n<td style=\"background: #ffffff; border-style: none; font-family: Courier New; font-size: 11pt; padding-left: 10px; padding-top: 0px; padding-bottom: 0px; color: #666666; white-space: nowrap; height: 15px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<\/td>\n<\/tr>\n<tr>\n<td style=\"background: #eeeeee; border-style: none; font-family: Courier New; font-size: 11pt; padding-left: 10px; padding-top: 0px; padding-bottom: 0px; color: #666666; white-space: nowrap; height: 15px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color: darkgreen; font-family: Courier New; font-size: 11pt;\">\/\/\u4ee5\u4e0b\u306e1\u6587\u3092\u52a0\u3048\u308b\u3002str\u306bShift_JIS\u5f62\u5f0f\u3067\u5909\u63db\u3055\u308c\u307e\u3059\u3002<br \/>\n<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"background: #ffffff; border-style: none; font-family: Courier New; font-size: 11pt; padding-left: 10px; padding-top: 0px; padding-bottom: 0px; color: #666666; white-space: nowrap; height: 15px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var str = iconv.decode(text, <span style=\"color: magenta; font-family: Courier New; font-size: 11pt;\">&#8216;Shift_JIS&#8217;<\/span>);<\/td>\n<\/tr>\n<tr>\n<td style=\"background: #eeeeee; border-style: none; font-family: Courier New; font-size: 11pt; padding-left: 10px; padding-top: 0px; padding-bottom: 0px; color: #666666; white-space: nowrap; height: 15px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0editor.setValue(str.toString(), \u20131);<\/td>\n<\/tr>\n<tr>\n<td style=\"background: #ffffff; border-style: none; font-family: Courier New; font-size: 11pt; padding-left: 10px; padding-top: 0px; padding-bottom: 0px; color: #666666; white-space: nowrap; height: 15px;\">\u00a0\u00a0\u00a0});<\/td>\n<\/tr>\n<tr>\n<td style=\"background: #eeeeee; border-style: none; font-family: Courier New; font-size: 11pt; padding-left: 10px; padding-top: 0px; padding-bottom: 0px; color: #666666; white-space: nowrap; height: 15px;\">}<\/td>\n<\/tr>\n<tr>\n<td style=\"background: #ffffff; border-style: none; font-family: Courier New; font-size: 11pt; padding-left: 10px; padding-top: 0px; padding-bottom: 0px; color: #666666; white-space: nowrap; height: 15px;\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>&nbsp;<\/p>\n<p>Electron\u306e\u9577\u6240\u306f\u69d8\u3005\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u3042\u308b\u3053\u3068\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002\u3044\u305a\u308c\u306b\u305b\u3088\u3001\u3053\u308c\u3067\u5148\u306b\u9032\u3081\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>&nbsp;<br \/>\n[ad#ad-1]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad#top-1] &nbsp; \u524d\u56de\u3001Shift-JIS\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":1358,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-1354","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-electron"],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/posts\/1354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/comments?post=1354"}],"version-history":[{"count":6,"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/posts\/1354\/revisions"}],"predecessor-version":[{"id":1796,"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/posts\/1354\/revisions\/1796"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/media\/1358"}],"wp:attachment":[{"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/media?parent=1354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/categories?post=1354"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pineplanter.moo.jp\/non-it-salaryman\/wp-json\/wp\/v2\/tags?post=1354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}