{"id":10100,"date":"2020-03-03T02:39:31","date_gmt":"2020-03-02T17:39:31","guid":{"rendered":"http:\/\/www.webcyou.com\/?p=10100"},"modified":"2020-03-03T02:50:14","modified_gmt":"2020-03-02T17:50:14","slug":"%e4%bb%a4%e5%92%8c%e3%81%ae%e6%99%82%e4%bb%a3%e3%81%ab%e3%80%81javascript%e3%81%a7-shift-jis%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e4%bd%9c%e6%88%90-%e5%85%a8%e9%8a%80%e3%83%87%e3%83%bc%e3%82%bf","status":"publish","type":"post","link":"https:\/\/www.webcyou.com\/?p=10100","title":{"rendered":"\u4ee4\u548c\u306e\u6642\u4ee3\u306b\u3001JavaScript\u3067 Shift-JIS\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210 \u5168\u9280\u30c7\u30fc\u30bf\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306b\u5bfe\u5fdc\u3059\u308b\u3002"},"content":{"rendered":"<p>\u3069\u3082\u3067\u3059\u3002<\/p>\n<p>\u3044\u3084\u3041\u3002<\/p>\n<p>\u4e16\u9593\u306f\u65b0\u578b\u30b3\u30ed\u30ca\u30a6\u30a3\u30eb\u30b9\u3067\u5927\u5909\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>\u5f53\u65b9\u3082\u3001\u5148\u9031\u982d\u304b\u3089\u30ea\u30e2\u30fc\u30c8\u30ef\u30fc\u30af\u306b\u5207\u308a\u66ff\u308f\u308a\u3001\u6b63\u306b\u4eca\u304b\u3089\u611f\u67d3\u304c\u5e83\u304c\u3063\u3066\u3044\u304f\u306e\u3060\u308d\u3046\u306a\u3041\u3002\u3068\u611f\u3058\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>\u5f8c\u624b\u5f8c\u624b\u3067\u3001\u30b0\u30c0\u30b0\u30c0\u3067\u7121\u8336\u82e6\u8336\u306a\u5bfe\u5fdc\u3067\u3001\u56fd\u5185\u5916\u3067\u304b\u306a\u308a\u306e\u653f\u6a29\u6279\u5224\u304c\u767a\u751f\u3057\u3066\u3044\u308b\u72b6\u6cc1\u3067\u3059\u304c\u3001<\/p>\n<p>\u307e\u3041\u4ed5\u65b9\u306a\u3044\u3067\u3059\u3088\u306d\u3002\u73fe\u653f\u6a29\u3060\u3068\u3002\u3002<\/p>\n<p>\u4f55\u304b\u3092\u671f\u5f85\u3059\u308b\u65b9\u304c\u304a\u304b\u3057\u3044\u3050\u3089\u3044\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3082\u3093\u306d\u3002<\/p>\n<p>\u304a\u304b\u3057\u3044\u306a\u3041\u3002\u3068\u601d\u3046\u3053\u3068\u306f\u5927\u4e8b\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>\u305d\u308c\u304b\u3089\u8272\u3005\u3068\u8abf\u3079\u3066\u884c\u304f\u3068\u8272\u3005\u3068\u898b\u3048\u308b\u3053\u3068\u3042\u308a\u307e\u3059\u3088\u306d\u3002<\/p>\n<p>\u3068\u3044\u3046\u4e8b\u3067\u3001\u6642\u4e8b\u306b\u95a2\u3057\u3066\u306f\u3053\u306e\u304f\u3089\u3044\u3067\u4eca\u56de\u306f\u3001\u4e45\u3005\u306b\u6587\u5b57\u30b3\u30fc\u30c9\u3068\u6226\u3063\u305f\u4e8b\u3082\u3042\u3063\u3066\u305d\u306e\u5099\u5fd8\u9332\u3067\u3082\u3068\u3002<\/p>\n<p>\u3044\u3044\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>\u3053\u306e<strong>\u4ee4\u548c\u306e\u6642\u4ee3\u306b\u3001 Shift-JIS\u3092\u6271\u3046<\/strong>\u306a\u3093\u3066\u3002<\/p>\n<p>\u6642\u4ee3\u3092\u9061\u3063\u305f\u611f\u3058\u3042\u3063\u3066\u3002<\/p>\n<p>\u3067\u3082\u3001\u6587\u5b57\u30b3\u30fc\u30c9\u3068\u6226\u3046\u306e\u304c\u30a8\u30f3\u30b8\u30cb\u30a2\u307d\u304f\u3066\u826f\u3044\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4>Shift-JIS\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210\u30fb\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/h4>\n<p>\u4eca\u56de\u3001<strong>CSV\u30d5\u30a1\u30a4\u30eb\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/strong>\u3068\u3001<strong>\u5168\u9280\u30c7\u30fc\u30bf\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u5f62\u5f0f\u306e\u30d5\u30a1\u30a4\u30eb<\/strong>\u306e<\/p>\n<p>JavaScript\u3067\u30d5\u30a1\u30a4\u30eb\u751f\u6210\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u306e\u65b9\u6cd5\u3092\u8a18\u8f09\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001<\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u751f\u6210\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u306e\u65b9\u6cd5\u3092\u5148\u306b\u30b3\u30fc\u30c9\u3092\u77e5\u308a\u305f\u3044\u65b9\u306f\u3053\u3061\u3089\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u30d5\u30a1\u30a4\u30eb\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3092\u884c\u3046\u95a2\u6570<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">export const downloadAsFile = (data) =&gt; {\r\n    const BLOB = new Blob(&#x5B;data.content], { type: data.type || 'text\/plain' })\r\n    const CAN_USE_SAVE_BLOB = window.navigator.msSaveBlob !== undefined\r\n\r\n    if (CAN_USE_SAVE_BLOB) {\r\n        window.navigator.msSaveBlob(BLOB, data.fileName)\r\n        return\r\n    }\r\n    const TEMP_ANCHOR = document.createElement('a')\r\n    TEMP_ANCHOR.href = URL.createObjectURL(BLOB)\r\n    TEMP_ANCHOR.setAttribute('download', data.fileName)\r\n    TEMP_ANCHOR.dispatchEvent(new MouseEvent('click'))\r\n}<\/pre>\n<p><strong>UTF-8\u6587\u5b57\u5217\u3092Shift-JIS\u6587\u5b57\u5217\u306b\u5909\u63db\u3059\u308b\u95a2\u6570<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">import Encoding from 'encoding-japanese'\r\n\r\ntoShiftJIS(utf8String) {\r\n    const detected = Encoding.detect(utf8String)\r\n    const unicodeList = &#x5B;]\r\n\r\n    for (let i = 0; i &lt; utf8String.length; i += 1) {\r\n        unicodeList.push(utf8String.charCodeAt(i))\r\n    }\r\n\r\n    const sjisArray = Encoding.convert(unicodeList, {\r\n        to: 'SJIS',\r\n        from: detected\r\n    })\r\n    return new Uint8Array(sjisArray)\r\n}<\/pre>\n<p>\u3068\u3001\u8a00\u3063\u305f\u611f\u3058\u3067\u3001\u4e3b\u8981\u306a\u95a2\u6570\u3092\uff12\u3064\u5148\u306b\u6319\u3052\u307e\u3057\u305f\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4>CSV\u30d5\u30a1\u30a4\u30eb\u00a0 \u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/h4>\n<p>Google \u30b9\u30d7\u30ec\u30c3\u30c8\u30b7\u30fc\u30c8\u7528\u306b\u3001CSV\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u51fa\u6765\u308b\u3088\u3046\u306b\u3059\u308b\u5fc5\u8981\u304c\u3042\u3063\u305f\u306e\u3067\u3059\u304c\u3001<\/p>\n<p>\u30c7\u30fc\u30bf\u81ea\u4f53\u306fAPI\u3067JSON\u3067\u53d7\u3051\u53d6\u308a\u3001\u305d\u308c\u3092CSV\u5f62\u5f0f\u306b\u5909\u63db\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u30d5\u30a1\u30a4\u30eb\u751f\u6210\u3057\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3002<\/p>\n<p>\u3068\u8a00\u3063\u305f\u6d41\u308c\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>CSV\u5f62\u5f0f\u306b\u3059\u308b\u306e\u306f\u3001\u30ab\u30f3\u30de\u533a\u5207\u308a\u306b\u3059\u308c\u3070\u826f\u3044\u3060\u3051\u306a\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u69d8\u306b\u30ab\u30f3\u30de\u533a\u5207\u308a\u306b\u6587\u5b57\u5217\u306b\u3059\u308c\u3070\u53d6\u308a\u6562\u3048\u305a\u306f\u30aa\u30c3\u30b1\u30fc\u3067\u3059\u306d\u3002<\/p>\n<p><strong>getCSVdata\u95a2\u6570<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">getCSVdata() {\r\n    return `${this.id},${this.ampseq},${this.transfee},${this.ct},${this.ut}...`\r\n}<\/pre>\n<p>\u4e0a\u8a18\u3067\u3082\u6319\u3052\u3055\u305b\u3066\u9802\u3044\u305f\u69d8\u306b\u3001\u30d5\u30a1\u30a4\u30eb\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3092\u884c\u3046\u95a2\u6570\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>\u30d5\u30a1\u30a4\u30eb\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3092\u884c\u3046\u95a2\u6570<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">export const downloadAsFile = (data) =&gt; {\r\n    const BLOB = new Blob(&#x5B;data.content], { type: data.type || 'text\/plain' })\r\n    const CAN_USE_SAVE_BLOB = window.navigator.msSaveBlob !== undefined\r\n\r\n    if (CAN_USE_SAVE_BLOB) {\r\n        window.navigator.msSaveBlob(BLOB, data.fileName)\r\n        return\r\n    }\r\n    const TEMP_ANCHOR = document.createElement('a')\r\n    TEMP_ANCHOR.href = URL.createObjectURL(BLOB)\r\n    TEMP_ANCHOR.setAttribute('download', data.fileName)\r\n    TEMP_ANCHOR.dispatchEvent(new MouseEvent('click'))\r\n}<\/pre>\n<p>\u307e\u305a\u3001\u5f15\u6570\u306edata\u306f\u300c<strong>fileName<\/strong>\u300d\u300c<strong>type<\/strong>\u300d\u300c<strong>content<\/strong>\u300d\u3092\u6301\u3063\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>fileName: \u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3059\u308b\u969b\u306e\u30d5\u30a1\u30a4\u30eb\u540d<\/p>\n<p>type:\u00a0MIME \u30bf\u30a4\u30d7<\/p>\n<p>content: \u30c7\u30fc\u30bf\u4e2d\u8eab<\/p>\n<p>\u3068\u8a00\u3063\u305f\u611f\u3058\u3067\u53d7\u3051\u53d6\u308a\u307e\u3059\u3002<\/p>\n<p>\u5f15\u6570\u304b\u3089\u300c<strong>content<\/strong>\u300d\u3068\u300c<strong>type<\/strong>\u300d\u3092\u53d7\u3051\u53d6\u3063\u3066\u3001Blob\u95a2\u6570\u3092\u7528\u3044\u3066Blob\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u751f\u6210\u3002<\/p>\n<p>\u305d\u306e\u5f8c\u3001navigator msSaveBlob API\u306e\u5b58\u5728\u306e\u6709\u7121\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<p>msSaveBlob\u306fIE\u306b\u7528\u610f\u3055\u308c\u3066\u3044\u308bAPI\u306a\u306e\u3067\u3001IE\u306e\u5834\u5408\u3092\u3053\u308c\u3089\u3092\u7528\u3044\u3066\u30d5\u30a1\u30a4\u30eb\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3092\u5b9f\u884c\u3002<\/p>\n<p>\u305d\u308c\u610f\u5916\u306f\u3001<strong>URL.createObjectURL<\/strong>\u3067URL\u3092\u751f\u6210\u3057\u3001a\u8981\u7d20\u3092\u751f\u6210\u3057\u64ec\u4f3c\u7684\u306b\u30af\u30ea\u30c3\u30af\u3057\u3066\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3055\u305b\u308b\u3068\u3044\u3063\u305f\u51e6\u7406\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u56de\u3057\u3066\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">let textData = `${headerString}\\n`\r\ntargetList.forEach(target =&gt; {\r\n    textData += `${target.getCSVdata()}\\n`\r\n})\r\ndownloadAsFile({\r\n    fileName: `${fileName}.csv`,\r\n    type: 'text\/csv',\r\n    content: textData\r\n})<\/pre>\n<p>CSV\u30d8\u30c3\u30c0\u30fc\u3082\u4ed8\u4e0e\u3057\u305f\u3044\u5834\u5408\u3092\u60f3\u5b9a\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u4e0a\u8a18\u306etarget\u306f\u3001getCSVdata\u95a2\u6570\u3092\u30e1\u30f3\u30d0\u306b\u6301\u3063\u305f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u60f3\u5b9a\u3067\u3059\u3002<\/p>\n<p>\u5fc5\u8981\u306a\u5206\u3060\u3051\u56de\u3057\u3066\u3001<strong>CSV\u5f62\u5f0f\u306estring\u306b\u5909\u63db<\/strong>\u3057\u3001\u5909\u6570textData\u306b\u8ffd\u52a0\u3057\u3001\u4e0a\u8a18\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u95a2\u6570\u3092\u5b9f\u884c\u3057\u30d5\u30a1\u30a4\u30eb\u3092\u751f\u6210\u3002<\/p>\n<p>\u3068\u8a00\u3063\u305f\u6d41\u308c\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u7279\u306b\u3001\u6587\u5b57\u30b3\u30fc\u30c9\u6307\u5b9a\u306a\u3051\u308c\u3070\u7c21\u5358\u306bCSV\u30d5\u30a1\u30a4\u30eb\u3092\u751f\u6210\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u51fa\u6765\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p><strong>\u5168\u9280\u30c7\u30fc\u30bf\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u00a0 \u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/strong><\/p>\n<p>\u3055\u3066\u3001\u672c\u984c\u306f\u3053\u3053\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>\u4eca\u56de\u3001\u5168\u9280\u30c7\u30fc\u30bf\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u5f62\u5f0f\u306e\u30d5\u30a1\u30a4\u30eb\u3092JavaScript\u3067\u4f5c\u6210\u3057\u3001\u30d5\u30a1\u30a4\u30eb\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u307e\u3067\u884c\u304a\u3046\u3068\u3044\u3063\u305f\u5185\u5bb9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u5168\u9280\u30c7\u30fc\u30bf\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3068\u306f\u306a\u3093\u305e\u3084\uff1f<\/p>\n<p>\u3068\u3044\u3046\u65b9\u306f\u3053\u3061\u3089\u3092\u5fa1\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><strong>\u5168\u9280\u30c7\u30fc\u30bf\u30d5\u30a9\u30fc\u30de\u30c3\u30c8<\/strong><\/p>\n<p><a href=\"http:\/\/www.hyogokenshin.co.jp\/wp-content\/uploads\/format1.pdf\" target=\"_blank\" rel=\"noopener\">http:\/\/www.hyogokenshin.co.jp\/wp-content\/uploads\/format1.pdf<\/a><\/p>\n<p>\u5168\u9280\u5354\u898f\u5b9a\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3068\u306f\u3001\u5168\u56fd\u9280\u884c\u5354\u4f1a\u9023\u5408\u4f1a\u304c\u30c7\u30fc\u30bf\u4f1d\u9001\u3092\u884c\u3046\u305f\u3081\u306b\u5b9a\u3081\u305f\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u7c21\u5358\u306b\u8aac\u660e\u3059\u308b\u3068\u3001\u9280\u884c\u632f\u8fbc\u3092\u884c\u3046\u305f\u3081\u306e\u632f\u308a\u8fbc\u307f\u30c7\u30fc\u30bf\u5f62\u5f0f\u3002\u3068\u3044\u3063\u305f\u3068\u3053\u308d\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u4e0a\u8a18\u306e\u5f62\u5f0f\u306b\u4f5c\u6210\u3057\u306a\u3044\u3068\u3059\u3050\u30a8\u30e9\u30fc\u3068\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u5927\u307e\u304b\u306b\u30dd\u30a4\u30f3\u30c8\u306f\u3001<\/p>\n<p><strong>\u30fb\u30d8\u30c3\u30c0\u30fc\u3001\u30c7\u30fc\u30bf\u3001\u30c8\u30ec\u30fc\u30e9\u30fc\u3001\u30a8\u30f3\u30c9\u30ec\u30b3\u30fc\u30c9\u306e\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3059\u308b<\/strong><\/p>\n<p><strong>\u30fb\u5404\u30ec\u30b3\u30fc\u30c9\u306f120\u6587\u5b57\uff08\u30d0\u30a4\u30c8\uff09\u3067\u4f5c\u6210\u3059\u308b<\/strong><\/p>\n<p><strong>\u30fb\u5404\u30ec\u30b3\u30fc\u30c9\u30c7\u30fc\u30bf\u306f\u30d0\u30a4\u30c8\u6570\u304c\u6c7a\u307e\u3063\u3066\u3044\u308b<\/strong><\/p>\n<p><strong>\u30fb\u534a\u89d2\u30ab\u30ca\u6587\u5b57\u3092\u4f7f\u7528<\/strong><\/p>\n<p><strong>\u30fbShift-JIS<\/strong><\/p>\n<p>\u6765\u307e\u3057\u305f\u306d\u3047\u3002Shift-JIS\u3002<\/p>\n<p>\u3082\u3046\u4f1a\u3046\u3053\u3068\u306a\u3044\u3068\u601d\u3063\u3066\u3044\u305f\u306e\u306b\u3001\u4ee4\u548c\u306e\u6642\u4ee3\u3067\u3053\u3093\u306b\u3061\u306f\u3002\u3067\u3059\u306d\u3002<\/p>\n<p>\u305d\u308c\u3067\u306f\u3001\u65e9\u901f\u5404\u30ec\u30b3\u30fc\u30c9\u751f\u6210\u306e\u95a2\u6570\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>\u5404\u30ec\u30b3\u30fc\u30c9<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">createHeaderRecord(data): string {\r\n    return `1210${data.consignorCode}${consignorName}${data.transferSpecifiedDate}${data.bankCode}${data.bankName}${data.bankBranchCode}${data.bankBranchName}${data.accountNo}                 `\r\n}\r\n\r\ncreateDataRecord(data): string {\r\n    const bankCode = data.bankCode\r\n    const bankName = data.bankName.padEnd(15, ' ')\r\n    const branchCode = data.branchCode\r\n    const branchName = data.branchName.padEnd(15, ' ')\r\n    const accountTypeNo = data.accountTypeNo\r\n    const accountNo = data.accountNo\r\n    const accountHolder = data.accountHolder.padEnd(30, ' ')\r\n    const transferAmount = data.transferAmount.padStart(10, '0')\r\n    return `2${bankCode}${bankName}${branchCode}${branchName}    ${accountTypeNo}${accountNo}${accountHolder}${transferAmount}1                             `\r\n}\r\n\r\ncreateFooterRecord(remittanceList): string {\r\n    const totalLength = remittanceList.length\r\n    const totalLengthString = String(totalLength).padStart(6, '0')\r\n    const totalPrice = sumBy(remittanceList, 'withdrawAmount')\r\n    const totalPriceString = String(totalPrice).padStart(12, '0')\r\n    const endEmptyString = ''.padEnd(101, ' ')\r\n    return `8${totalLengthString}${totalPriceString}${endEmptyString}`\r\n}\r\n\r\ncreateEndRecord() {\r\n    return '9'.padEnd(120, ' ')\r\n}<\/pre>\n<p>\u307e\u305a\u3001\u30d8\u30c3\u30c0\u30fc\u30ec\u30b3\u30fc\u30c9\u3092\u751f\u6210\u3059\u308b\u300ccreateHeaderRecord\u95a2\u6570\u300d\u3002<\/p>\n<p>\u3053\u3061\u3089\u306f\u3001\u52d5\u7684\u3067\u306a\u3044\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u60f3\u5b9a\u3057\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u305d\u306e\u307e\u307e\u8a2d\u5b9a\u3055\u308c\u305f\u5024\u3092string\u3067\u8fd4\u5374\u3057\u307e\u3059\u3002<\/p>\n<p>\u30a8\u30f3\u30c9\u30ec\u30b3\u30fc\u30c9\u3092\u751f\u6210\u3059\u308b\u300ccreateEndRecord\u95a2\u6570\u300d\u3082\u540c\u69d8\u3067\u3059\u306d\u3002<\/p>\n<p>\u8868\u793a\u306f\u30019\u306e\u307f\u30671\u884c120\u6587\u5b57\u306estring\u3092\u8fd4\u5374\u3002<\/p>\n<p>\u305d\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u3001\u300ccreateHeaderRecord\u95a2\u6570\u3001createEndRecord\u95a2\u6570\u300d\u306f\u3001\u3061\u3087\u3063\u3068\u5272\u611b\u3055\u305b\u3066\u3082\u3089\u3044\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u3067\u3001\u5927\u4e8b\u306a\u306e\u306f\u3001\u300ccreateDataRecord\u95a2\u6570\u300d\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u306e\u6570\u3060\u3051\u547c\u3073\u51fa\u3057\u3092\u884c\u3044\u3001\u30ec\u30b3\u30fc\u30c9\u3092\u4f5c\u6210\u3057\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u30ec\u30b3\u30fc\u30c9\u306f2\u59cb\u307e\u308a\u3067\u3001\u3068\u3053\u308d\u3069\u3053\u308d\u30b9\u30da\u30fc\u30b9\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u30c7\u30fc\u30bf\u3092\u57cb\u3081\u308b\u305f\u3081\u306e\u30b9\u30da\u30fc\u30b9\u3067\u3001<\/p>\n<p>emptyString\u3068\u3057\u3066\u3001\u5909\u6570\u3092\u4f5c\u6210\u3057\u3066\u3082\u826f\u3044\u3067\u3059\u306d\u3002<\/p>\n<p>\u9280\u884c\u30c7\u30fc\u30bf\u306b\u95a2\u3059\u308b\u3082\u306e\u306a\u3069\u306f\u3001ECMA2017\u306eAPI\u3001padStart\u3068padEnd\u3067\u30bc\u30ed\u30d1\u30c7\u30a3\u30f3\u30b0&amp;\u30b9\u30da\u30fc\u30b9\u57cb\u3081\u3092\u884c\u3044\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3057\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30c8\u30ec\u30fc\u30e9\u30fc\u30ec\u30b3\u30fc\u30c9\u751f\u6210\u306e\u300ccreateFooterRecord\u95a2\u6570\u300d\u306f\u3001\u5404\u632f\u308a\u8fbc\u307f\u30c7\u30fc\u30bf\u6570\u3084\u632f\u8fbc\u984d\u5408\u8a08\u3068\u306a\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>sumBy\u306f\u3001lodash\u4f7f\u7528\u3057\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u3068\u3044\u3063\u305f\u8a33\u3067\u3001\u3053\u3061\u3089\u3092\u5229\u7528\u3057\u3066\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u4e0a\u8a18\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u95a2\u6570\u3067\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3002<\/p>\n<p>\u3053\u308c\u3067\u3001\u884c\u3051\u305f\u3060\u308d\u3046\u3002\u3068\u8a66\u3057\u305f\u3068\u3053\u308d\u3002<\/p>\n<p>&nbsp;<\/p>\n<div>\n<p>    <span style=\"color: #ff0000;\">\u30a8\u30e9\u30fc\uff11\u884c120\u30d0\u30a4\u30c8\u00a0<\/span><\/p>\n<\/div>\n<p>\u306a\u3093\u3068\u3002\u3002\u3002<\/p>\n<p>\u4f55\u304c\u539f\u56e0\u3060\uff1f\u8abf\u3079\u3066\u307f\u308b\u3068\u3053\u308d\u3001\u6539\u884c\u30b3\u30fc\u30c9\u3067\u306f\uff1f<\/p>\n<p>\u3068\u884c\u304d\u7740\u3044\u305f\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u6587\u5b57\u30b3\u30fc\u30c9\u3068\u6539\u884c\u30b3\u30fc\u30c9<\/strong><\/p>\n<table>\n<colgroup>\n<col \/>\n<col \/>\n<col \/>\n<col \/><\/colgroup>\n<thead>\n<tr>\n<th style=\"text-align: center;\">OS<\/th>\n<th style=\"text-align: center;\">\u6587\u5b57\u30b3\u30fc\u30c9<\/th>\n<th style=\"text-align: center;\">\u6539\u884c\u30b3\u30fc\u30c9<\/th>\n<th style=\"text-align: center;\">\u6539\u884c\u30b3\u30fc\u30c9\u306e\u5927\u304d\u3055<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">Windows<\/td>\n<td style=\"text-align: center;\">\u30b7\u30d5\u30c8JIS<\/td>\n<td style=\"text-align: center;\">CR+LF<\/td>\n<td style=\"text-align: center;\">\uff12\u30d0\u30a4\u30c8<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">Mac OS<\/td>\n<td style=\"text-align: center;\">\u30b7\u30d5\u30c8JIS<\/td>\n<td style=\"text-align: center;\">CR<\/td>\n<td style=\"text-align: center;\">\uff11\u30d0\u30a4\u30c8<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">Mac OS X<\/td>\n<td style=\"text-align: center;\">EUC<\/td>\n<td style=\"text-align: center;\">LF<\/td>\n<td style=\"text-align: center;\">\uff11\u30d0\u30a4\u30c8<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">UNIX<\/td>\n<td style=\"text-align: center;\">EUC<\/td>\n<td style=\"text-align: center;\">LF<\/td>\n<td style=\"text-align: center;\">\uff11\u30d0\u30a4\u30c8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"color: #ff0000;\"><strong>\u5168\u9280\u30c7\u30fc\u30bf\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306f\u3001\u6700\u5f8c\uff12\u30d0\u30a4\u30c8\u6539\u884c\u3002<\/strong><\/span><\/p>\n<p>\u3058\u3083\u306a\u3044\u3068\u884c\u3051\u306a\u3044\u3088\u3046\u3060\u3002\u3002<\/p>\n<p>\u3046\u30fc\u3093\u3002\u3002\u78ba\u304b\u306b\u3002<\/p>\n<p>1\u30d0\u30a4\u30c8\u3067\u6539\u884c\u3092\u884c\u3063\u3066\u3044\u305f\u306e\u3067\u3001\u4fee\u6b63\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">'\\n' \u2192 '\\r\\n'<\/pre>\n<p>\u3088\u3057\uff01<\/p>\n<p>\u3053\u308c\u3067\u5927\u4e08\u592b\u3060\u308d\u3046\uff01\uff01<\/p>\n<p>\u3068\u30c6\u30b9\u30c8\u3092\u884c\u3063\u3066\u307f\u308b\u3068\u3002<\/p>\n<p>\u307e\u305f\u3057\u3066\u3082\u3001<\/p>\n<p><span style=\"color: #ff0000;\">\u30a8\u30e9\u30fc\u00a0\uff11\u884c120\u30d0\u30a4\u30c8<\/span><\/p>\n<p>\u30d5\u30a1\u3002<\/p>\n<p>\u751f\u6210\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u76ee\u8996\u3067\u898b\u3066\u307f\u308b\u3068\u3001\u3046\u3093\uff1f\uff1f<\/p>\n<p>\u30cf\u30a4\u30d5\u30f3\u304c\u306a\u3093\u304b\u5909\u306a\u6c17\u304c\u3059\u308b\u3002\u3002<\/p>\n<p>\u305d\u3046\u3002<\/p>\n<p>\u9280\u884c\u30b3\u30fc\u30c9\u306b\u306f\u3001\u300c<strong>zengin-code<\/strong>\u300d\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f7f\u7528\u3057\u3066\u3044\u3066\u3001<\/p>\n<p><strong>github<\/strong><\/p>\n<p><a href=\"https:\/\/github.com\/zengin-code\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/zengin-code<\/a><\/p>\n<p>\u300c\u534a\u89d2\u30ab\u30bf\u30ab\u30ca\u300d\u5909\u63db\u306b\u306f\u3001\u300c<strong>moji<\/strong>\u300d\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001<\/p>\n<p><strong>github<\/strong><\/p>\n<p><a href=\"https:\/\/github.com\/niwaringo\/moji\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/niwaringo\/moji<\/a><\/p>\n<p>\uff08\u3053\u3061\u3089\u3001\u6700\u5f8c\u306e\u4fee\u6b63\u304c npm publish\u3055\u308c\u3066\u3044\u306a\u3044\u3068\u3053\u308d\u3092\u6ce8\u610f\u3002\uff09<\/p>\n<p>\u300c<strong>zengin-code<\/strong>\u300d\u306e \u300c\u30df\u30c4\u30d3\u30b7\u30e6\uff0d\u30a8\u30d5\u30b8\u30a8\u30a4\u300d\u304c\u3069\u3046\u3082\u5909\u306a\u6c17\u304c\u3059\u308b\u3002\u3002<\/p>\n<p>\u8abf\u3079\u305f\u3068\u3053\u308d\u3001<span style=\"color: #1d1c1d;\">ASCII\u306e\u30cf\u30a4\u30d5\u30f3\u3068\u3044\u3046\u3053\u3068\u304c\u308f\u304b\u308b\u3002<\/span><\/p>\n<p>\u3068\u3001\u540c\u6642\u306b\u3053\u3093\u306a\u306b\u30cf\u30a4\u30d5\u30f3\u3042\u3063\u305f\u306e\u304b\u3088\u30fc\u30fc\u30fc\u3068\u3002<\/p>\n<table>\n<colgroup>\n<col \/>\n<col \/>\n<col \/>\n<col \/><\/colgroup>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u6587\u5b57<\/th>\n<th style=\"text-align: left;\">UTF-8<\/th>\n<th style=\"text-align: left;\">Unicode<\/th>\n<th style=\"text-align: left;\">\u8aac\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>&#8211;<\/td>\n<td>2D<\/td>\n<td>U+002D<\/td>\n<td>ASCII\u306e\u30cf\u30a4\u30d5\u30f3<\/td>\n<\/tr>\n<tr>\n<td>\u30fc<\/td>\n<td>E383BC<\/td>\n<td>U+30FC<\/td>\n<td>\u5168\u89d2\u306e\u9577\u97f3<\/td>\n<\/tr>\n<tr>\n<td>\u2010<\/td>\n<td>E28090<\/td>\n<td>U+2010<\/td>\n<td>\u5225\u306e\u30cf\u30a4\u30d5\u30f3<\/td>\n<\/tr>\n<tr>\n<td>\u2011<\/td>\n<td>E28091<\/td>\n<td>U+2011<\/td>\n<td>\u6539\u884c\u3057\u306a\u3044\u30cf\u30a4\u30d5\u30f3<\/td>\n<\/tr>\n<tr>\n<td>\u2013<\/td>\n<td>E28093<\/td>\n<td>U+2013<\/td>\n<td>EN\u30c0\u30c3\u30b7\u30e5<\/td>\n<\/tr>\n<tr>\n<td>\u2014<\/td>\n<td>E28094<\/td>\n<td>U+2014<\/td>\n<td>EM\u30c0\u30c3\u30b7\u30e5<\/td>\n<\/tr>\n<tr>\n<td>\u2015<\/td>\n<td>E28095<\/td>\n<td>U+2015<\/td>\n<td>\u5168\u89d2\u306e\u30c0\u30c3\u30b7\u30e5<\/td>\n<\/tr>\n<tr>\n<td>\u2212<\/td>\n<td>E28892<\/td>\n<td>U+2212<\/td>\n<td>\u5168\u89d2\u306e\u30de\u30a4\u30ca\u30b9<\/td>\n<\/tr>\n<tr>\n<td>\uff70<\/td>\n<td>EFBDB0<\/td>\n<td>U+FF70<\/td>\n<td>\u534a\u89d2\u30ab\u30ca\u306e\u9577\u97f3<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><strong>\u53c2\u8003\u30da\u30fc\u30b8\uff08\u52a9\u304b\u308a\u307e\u3057\u305f\uff09<\/strong><\/p>\n<p><a href=\"https:\/\/qiita.com\/ryounagaoka\/items\/4cf5191d1a2763667add\" target=\"_blank\" rel=\"noopener\">https:\/\/qiita.com\/ryounagaoka\/items\/4cf5191d1a2763667add<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u306a\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u69d8\u306b\u300c<strong>moji<\/strong>\u300d\u3092\u4f7f\u3044\u3064\u3064\u3001\u62e1\u5f35\u3057\u3066\u3002<\/p>\n<p>\u3053\u308c\u3067\u3001\u554f\u984c\u306a\u3044\u3060\u308d\u3046\uff01\uff01<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u8ffd\u52a0<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">getReplaceHankakuKana(zenkakuKana) {\r\n    const hankakuKana = moji(zenkakuKana)\r\n        .convert('ZKtoHK')\r\n        .toString()\r\n    return hankakuKana.replace(\/(\uff0d|\u30fc)\/g, '\uff70')\r\n}<\/pre>\n<p>\u3088\u3057\u3002<\/p>\n<p>\u3053\u308c\u3067OK\u3067\u3059\u3088\u306d\uff01\uff1f<\/p>\n<p><span style=\"color: #ff0000;\">\u30a8\u30e9\u30fc \uff11\u884c120\u30d0\u30a4\u30c8<\/span><\/p>\n<p>\u30d5\u30a1\u3002<\/p>\n<p>\u306a\u3001\u306a\u3001\u306a\u3093\u3060\u3088\u3002\u3002\u3002<\/p>\n<p>\u3046\u3093\uff1f<\/p>\n<p>\u305d\u3082\u305d\u3082\u6587\u5b57\u30b3\u30fc\u30c9\u5909\u63db\u3057\u3066\u3044\u306a\u3044\u306a\u3041\u3002\u3002<\/p>\n<p>\u3068\u3044\u3046\u4e8b\u3067\u3001\u6587\u5b57\u30b3\u30fc\u30c9\u3001\u30d5\u30a1\u30a4\u30eb\u5f62\u5f0f\u8abf\u3079\u3066\u307f\u308b\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ file --mime .\/202002_zengin.txt<\/pre>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ text\/plain; charset=utf-8<\/pre>\n<p>\u306f\u3044\u3002UTF-8\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e0a\u8a18\u306edownloadAsFile\u95a2\u6570\u3067\u3001MIME \u30bf\u30a4\u30d7\u3092\u4ee5\u4e0b\u306e\u69d8\u306b\u6307\u5b9a\u3057\u3066\u307f\u308b\u304c\u9069\u5fdc\u3055\u308c\u306a\u3044\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">type: 'text\/plain; charset=shift_jis',&#x5B;code]\r\n\r\n&lt;strong&gt;downloadAsFile\u95a2\u6570&lt;\/strong&gt;\r\n\r\n&#x5B;code]downloadAsFile({\r\n    fileName: `${formattedDate(remittanceList&#x5B;0].remittanceDate, 'YYYYMM')}_zengin.txt`,\r\n    type: 'text\/plain; charset=shift_jis',\r\n    content: this.toShiftJIS(textData)\r\n})\r\n\u00a0\r\ndownloadAsFile(data) {\r\n  const BLOB = new Blob(&#x5B;data.content], { type: data.type || 'text\/plain' })<\/pre>\n<p>\u3046\u30fc\u3093\u3002\u51fa\u6765\u306a\u3044\u306e\u304b\u3002\u3002\u4e00\u65e6\u30b3\u30de\u30f3\u30c9\u5909\u63db\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>iconv\u30b3\u30de\u30f3\u30c9\u5909\u63db<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ iconv -f utf8 -t sjis 202002_zengin.txt &gt; 202002_zengin.txt\r\n$ text\/plain; charset=iso-8859-1<\/pre>\n<p>\u3068\u3001\u5909\u63db\u3057\u3066\u30c6\u30b9\u30c8\u3092\u884c\u3046\u3068\u554f\u984c\u306a\u304f\u901a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4>encoding.js\u3067\u3001Shift-JIS\u5909\u63db<\/h4>\n<p>\u3055\u3066\u3001\u6bce\u5ea6\u30b3\u30de\u30f3\u30c9\u53e9\u304d\u305f\u304f\u306a\u3044\u306e\u3067JS\uff08\u30d6\u30e9\u30a6\u30b6\uff09\u3067\u3001\u51e6\u7406\u306f\u7d42\u308f\u3089\u305b\u305f\u3044\u3002\u3068\u3002<\/p>\n<p>\u826f\u3055\u305d\u3046\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u63a2\u3059\u3068\u3053\u308d\u3001\u300cencoding.js\u300d\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u826f\u3055\u305d\u3046\u306a\u306e\u3067\u65e9\u901f\u5229\u7528\u3057\u3066\u307f\u308b\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><strong>encoding-japanese<\/strong><\/p>\n<p><a href=\"https:\/\/github.com\/polygonplanet\/encoding.js\">https:\/\/github.com\/polygonplanet\/encoding.js<\/a><\/p>\n<p>npm\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ npm install encoding-japanese&lt;<\/pre>\n<p>\u5909\u63db\u3067\u304d\u308b\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u5f62\u5f0f\u306f\u4ee5\u4e0b\u306e\u30d0\u30ea\u30a8\u30fc\u30b7\u30e7\u30f3\u306e\u69d8\u3067\u3059\u3002<\/p>\n<ul>\n<li>&#8216;UTF32&#8217; (detect only)<\/li>\n<li>&#8216;UTF16&#8217;<\/li>\n<li>&#8216;UTF16BE&#8217;<\/li>\n<li>&#8216;UTF16LE&#8217;<\/li>\n<li>&#8216;BINARY&#8217; (detect only)<\/li>\n<li>&#8216;ASCII&#8217; (detect only)<\/li>\n<li>&#8216;JIS&#8217;<\/li>\n<li>&#8216;UTF8&#8217;<\/li>\n<li>&#8216;EUCJP&#8217;<\/li>\n<li>&#8216;SJIS&#8217;<\/li>\n<li>&#8216;UNICODE&#8217; (JavaScript Unicode Array)<\/li>\n<\/ul>\n<p>UTF-8\u5f62\u5f0f\u304b\u3089\u5909\u63db\u3057\u306a\u3044\u3068\u306a\u3002\u3068\u304b\u601d\u3063\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001<\/p>\n<p>\u300cEncoding.detect\u95a2\u6570\u300d\u3067\u6587\u5b57\u30b3\u30fc\u30c9\u3092\u78ba\u8a8d\u51fa\u6765\u308b\u306e\u3067\u3059\u304c\u3001\u78ba\u8a8d\u3059\u308b\u3068\u3053\u308d\u300cUNICODE(JavaScript Unicode Array)\u300d\u5f62\u5f0f\u306a\u306e\u304b\u3088\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">Encoding.detect(textData)\r\nUNICODE<\/pre>\n<p>\u3067\u306f\u3001\u3053\u308c\u3067\u5909\u63db\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">toShiftJIS(utf8Array) {\r\n    const detected = Encoding.detect(utf8Array)\r\n    return Encoding.convert(unicodeList, {\r\n        to: 'SJIS',\r\n        from: detected\r\n    })\r\n}<\/pre>\n<p>\u884c\u3051\u305f\u3067\u3057\u3087\u3002\uff1f<\/p>\n<p>\u3068\u601d\u3063\u3066\u3044\u305f\u3089\u3001MIME \u30bf\u30a4\u30d7 \u6587\u5b57\u30b3\u30fc\u30c9\u3082\u5909\u63db\u3055\u308c\u305a\u3001\u6587\u5b57\u5316\u3051\u3059\u308b\u59cb\u672b\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ text\/plain; charset=utf-8<\/pre>\n<p>\u304a\u3088\u3088\u3002\u3002<\/p>\n<p>\u3068\u3001\u3075\u3068\u8003\u3048\u308b\u3068\u3053\u308c\u306f\u3001\u4e00\u6587\u5b57\u305a\u3064\u5909\u63db\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u306a\u3002\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u306b\u6c17\u304c\u3064\u304f\u3002<\/p>\n<p>\u3068\u3044\u3046\u308f\u3051\u3067\u30011\u6587\u5b57\u5358\u4f4d\u3067\u5909\u63db\u3059\u308b\u3053\u3068\u306b\u3059\u308b\u3002<\/p>\n<p>\u307e\u305f\u3001charCodeAt\u95a2\u6570\u3067UTF-16 \u30b3\u30fc\u30c9\u30e6\u30cb\u30c3\u30c8\u5f62\u5f0f\u306b\u5909\u63db\u3057\u3001\u914d\u5217\u306b\u683c\u7d0d\u3002<\/p>\n<p>Encoding.convert\u3067\u3001SJIS\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306b\u5909\u63db\u3002<\/p>\n<p>ES2017\u306eAPI\u3067\u3042\u308b\u3001Uint8Array\u3067\u3001\u8ca0\u306e\u6570\u306a\u3057\u6574\u6570(Unsigned int)\u306e\u914d\u5217\u306e\u30d0\u30a4\u30ca\u30ea\u5909\u63db\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">toShiftJIS(utf8Array) {\r\n    const detected = Encoding.detect(utf8Array)\r\n    const unicodeList = &#x5B;]\r\n    for (let i = 0; i &lt; utf8Array.length; i += 1) {\r\n        unicodeList.push(utf8Array.charCodeAt(i))\r\n    }\r\n    const sjisArray = Encoding.convert(unicodeList, {\r\n        to: 'SJIS',\r\n        from: detected\r\n    })\r\n    return new Uint8Array(sjisArray)\r\n}<\/pre>\n<p><strong>utf8Array.charCodeAt<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;12362, 12414, 12360, 12399, 12354, 12411, 12363, 32, 32, 32, 32, 32, 32, 32, 32,...]<\/pre>\n<p><strong>new Uint8Array(sjisArray)<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">&#x5B;74, 126, 72, 111, 66, 123, 75]<\/pre>\n<p>\u3053\u308c\u3067\u3001\u554f\u984c\u306a\u3044\u3067\u3057\u3087\u3002<\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u5909\u63db\u5b8c\u4e86<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ text\/plain; charset=iso-8859-1<\/pre>\n<p>\u304a\uff01<\/p>\n<p>MIME \u30bf\u30a4\u30d7\u3082\u5909\u63db\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u3067\u3082\u3001iso-8859-1\u306a\u306e\u3067\u3059\u306d\u3002<\/p>\n<p>\u30c6\u30b9\u30c8\u3059\u308b\u3068\u3053\u308d\u3002\u3002<\/p>\n<p>\u30aa\u30c3\u30b1\u30fc\u3067\u3057\u305f\u30fc\u3002<\/p>\n<p>\u3068\u3001\u9577\u3005\u66f8\u3044\u3066\u304d\u307e\u3057\u305f\u304c\u3001\u4e45\u3005 JS\u3067\u6587\u5b57\u30b3\u30fc\u30c9\u3068\u6226\u3063\u305f\u30ed\u30b0\u3067\u3057\u305f\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u3041\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3069\u3082\u3067\u3059\u3002 \u3044\u3084\u3041\u3002 \u4e16\u9593\u306f\u65b0\u578b\u30b3\u30ed\u30ca\u30a6\u30a3\u30eb\u30b9\u3067\u5927\u5909\u3067\u3059\u3088\u306d\u3002 \u5f53\u65b9\u3082\u3001\u5148\u9031\u982d\u304b\u3089\u30ea\u30e2\u30fc\u30c8\u30ef\u30fc\u30af\u306b\u5207\u308a\u66ff\u308f\u308a\u3001\u6b63\u306b\u4eca\u304b\u3089\u611f\u67d3\u304c\u5e83\u304c\u3063\u3066\u3044\u304f\u306e\u3060\u308d\u3046\u306a\u3041\u3002\u3068\u611f\u3058\u3066\u304a\u308a\u307e\u3059\u3002 \u5f8c\u624b\u5f8c\u624b\u3067\u3001\u30b0\u30c0\u30b0\u30c0\u3067\u7121\u8336\u82e6\u8336\u306a\u5bfe\u5fdc\u3067\u3001\u56fd\u5185\u5916\u3067 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[171,59,167,177,168,176,166,47,179,50,46,45,111,95,39,55,178,138,78,114,118],"class_list":["post-10100","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-android","tag-android-sdk","tag-css","tag-css3","tag-html","tag-html5","tag-iphone","tag-javascript-2","tag-jquery","tag-jquery-mobile","tag-js","tag-web","tag-wordpress-2","tag-95","tag-39","tag-55","tag-178","tag-138","tag-78","tag-114","tag-118"],"_links":{"self":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/10100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10100"}],"version-history":[{"count":25,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/10100\/revisions"}],"predecessor-version":[{"id":10128,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/10100\/revisions\/10128"}],"wp:attachment":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}