質問編集履歴
8
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -94,6 +94,8 @@
|
|
94
94
|
|
95
95
|
import * as fs from 'fs-extra'
|
96
96
|
|
97
|
+
import iconv from 'iconv-lite'
|
98
|
+
|
97
99
|
let csvStr = 'あ'
|
98
100
|
|
99
101
|
fs.writeFileSync(outputFilePath, '')
|
7
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -92,9 +92,9 @@
|
|
92
92
|
|
93
93
|
// fsじゃなくてfs-extraを使ってます
|
94
94
|
|
95
|
-
|
95
|
+
import * as fs from 'fs-extra'
|
96
96
|
|
97
|
-
|
97
|
+
let csvStr = 'あ'
|
98
98
|
|
99
99
|
fs.writeFileSync(outputFilePath, '')
|
100
100
|
|
6
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -84,10 +84,6 @@
|
|
84
84
|
|
85
85
|
|
86
86
|
|
87
|
-
let csvStr = あ
|
88
|
-
|
89
|
-
|
90
|
-
|
91
87
|
```js
|
92
88
|
|
93
89
|
// 参考サイト
|
@@ -96,7 +92,7 @@
|
|
96
92
|
|
97
93
|
// fsじゃなくてfs-extraを使ってます
|
98
94
|
|
99
|
-
|
95
|
+
let csvStr = あ
|
100
96
|
|
101
97
|
import * as fs from 'fs-extra'
|
102
98
|
|
@@ -107,3 +103,5 @@
|
|
107
103
|
let buf = iconv.encode(csvStr, 'Shift_JIS')
|
108
104
|
|
109
105
|
await fs.writeSync(fd, buf, 0, buf.length)
|
106
|
+
|
107
|
+
```
|
5
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -106,6 +106,4 @@
|
|
106
106
|
|
107
107
|
let buf = iconv.encode(csvStr, 'Shift_JIS')
|
108
108
|
|
109
|
-
await fs.writeSync(fd, buf, 0, buf.leng
|
109
|
+
await fs.writeSync(fd, buf, 0, buf.length)
|
110
|
-
|
111
|
-
```th)
|
4
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -94,6 +94,12 @@
|
|
94
94
|
|
95
95
|
// https://photo-tea.com/p/17/nodejs-write-excel-tsv-csv/
|
96
96
|
|
97
|
+
// fsじゃなくてfs-extraを使ってます
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
import * as fs from 'fs-extra'
|
102
|
+
|
97
103
|
fs.writeFileSync(outputFilePath, '')
|
98
104
|
|
99
105
|
let fd = fs.openSync(outputFilePath, 'w')
|
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -71,3 +71,35 @@
|
|
71
71
|
}
|
72
72
|
|
73
73
|
```
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
-------------------
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
追記
|
82
|
+
|
83
|
+
SJISのファイルの作り方
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
let csvStr = あ
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
```js
|
92
|
+
|
93
|
+
// 参考サイト
|
94
|
+
|
95
|
+
// https://photo-tea.com/p/17/nodejs-write-excel-tsv-csv/
|
96
|
+
|
97
|
+
fs.writeFileSync(outputFilePath, '')
|
98
|
+
|
99
|
+
let fd = fs.openSync(outputFilePath, 'w')
|
100
|
+
|
101
|
+
let buf = iconv.encode(csvStr, 'Shift_JIS')
|
102
|
+
|
103
|
+
await fs.writeSync(fd, buf, 0, buf.leng
|
104
|
+
|
105
|
+
```th)
|
2
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,11 +52,11 @@
|
|
52
52
|
|
53
53
|
|
54
54
|
|
55
|
-
text = convertSjisS
|
55
|
+
text = convertSjisStrToUtf8Str(text) // => [63]
|
56
56
|
|
57
57
|
|
58
58
|
|
59
|
-
const convertSjisS
|
59
|
+
const convertSjisStrToUtf8Str = (sjisStr) => {
|
60
60
|
|
61
61
|
let ary = []
|
62
62
|
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -33,3 +33,41 @@
|
|
33
33
|
|
34
34
|
|
35
35
|
textをこの形式に一旦変換してからEncoding.convertしてみようかなと思うのですが、それは可能なのでしょうか。
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
-------------------
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
追記
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
```js
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
// textはSJISの"あ"
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
text = convertSjisSotrToUtf8Str(text) // => [63]
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
const convertSjisSotrToUtf8Str = (sjisStr) => {
|
60
|
+
|
61
|
+
let ary = []
|
62
|
+
|
63
|
+
for (let index = 0; index < sjisStr.length; index++) {
|
64
|
+
|
65
|
+
ary.push(sjisStr.charCodeAt(index))
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
return Encoding.convert(ary, 'UNICODE', 'SJIS')
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
```
|