質問編集履歴
8
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -46,6 +46,7 @@
|
|
46
46
|
// https://photo-tea.com/p/17/nodejs-write-excel-tsv-csv/
|
47
47
|
// fsじゃなくてfs-extraを使ってます
|
48
48
|
import * as fs from 'fs-extra'
|
49
|
+
import iconv from 'iconv-lite'
|
49
50
|
let csvStr = 'あ'
|
50
51
|
fs.writeFileSync(outputFilePath, '')
|
51
52
|
let fd = fs.openSync(outputFilePath, 'w')
|
7
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -45,8 +45,8 @@
|
|
45
45
|
// 参考サイト
|
46
46
|
// https://photo-tea.com/p/17/nodejs-write-excel-tsv-csv/
|
47
47
|
// fsじゃなくてfs-extraを使ってます
|
48
|
-
let csvStr = あ
|
49
48
|
import * as fs from 'fs-extra'
|
49
|
+
let csvStr = 'あ'
|
50
50
|
fs.writeFileSync(outputFilePath, '')
|
51
51
|
let fd = fs.openSync(outputFilePath, 'w')
|
52
52
|
let buf = iconv.encode(csvStr, 'Shift_JIS')
|
6
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -41,15 +41,14 @@
|
|
41
41
|
追記
|
42
42
|
SJISのファイルの作り方
|
43
43
|
|
44
|
-
let csvStr = あ
|
45
|
-
|
46
44
|
```js
|
47
45
|
// 参考サイト
|
48
46
|
// https://photo-tea.com/p/17/nodejs-write-excel-tsv-csv/
|
49
47
|
// fsじゃなくてfs-extraを使ってます
|
50
|
-
|
48
|
+
let csvStr = あ
|
51
49
|
import * as fs from 'fs-extra'
|
52
50
|
fs.writeFileSync(outputFilePath, '')
|
53
51
|
let fd = fs.openSync(outputFilePath, 'w')
|
54
52
|
let buf = iconv.encode(csvStr, 'Shift_JIS')
|
55
|
-
await fs.writeSync(fd, buf, 0, buf.length)
|
53
|
+
await fs.writeSync(fd, buf, 0, buf.length)
|
54
|
+
```
|
5
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -52,5 +52,4 @@
|
|
52
52
|
fs.writeFileSync(outputFilePath, '')
|
53
53
|
let fd = fs.openSync(outputFilePath, 'w')
|
54
54
|
let buf = iconv.encode(csvStr, 'Shift_JIS')
|
55
|
-
await fs.writeSync(fd, buf, 0, buf.
|
55
|
+
await fs.writeSync(fd, buf, 0, buf.length)
|
56
|
-
```th)
|
4
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -46,6 +46,9 @@
|
|
46
46
|
```js
|
47
47
|
// 参考サイト
|
48
48
|
// https://photo-tea.com/p/17/nodejs-write-excel-tsv-csv/
|
49
|
+
// fsじゃなくてfs-extraを使ってます
|
50
|
+
|
51
|
+
import * as fs from 'fs-extra'
|
49
52
|
fs.writeFileSync(outputFilePath, '')
|
50
53
|
let fd = fs.openSync(outputFilePath, 'w')
|
51
54
|
let buf = iconv.encode(csvStr, 'Shift_JIS')
|
3
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -34,4 +34,20 @@
|
|
34
34
|
}
|
35
35
|
return Encoding.convert(ary, 'UNICODE', 'SJIS')
|
36
36
|
}
|
37
|
-
```
|
37
|
+
```
|
38
|
+
|
39
|
+
-------------------
|
40
|
+
|
41
|
+
追記
|
42
|
+
SJISのファイルの作り方
|
43
|
+
|
44
|
+
let csvStr = あ
|
45
|
+
|
46
|
+
```js
|
47
|
+
// 参考サイト
|
48
|
+
// https://photo-tea.com/p/17/nodejs-write-excel-tsv-csv/
|
49
|
+
fs.writeFileSync(outputFilePath, '')
|
50
|
+
let fd = fs.openSync(outputFilePath, 'w')
|
51
|
+
let buf = iconv.encode(csvStr, 'Shift_JIS')
|
52
|
+
await fs.writeSync(fd, buf, 0, buf.leng
|
53
|
+
```th)
|
2
誤字
title
CHANGED
File without changes
|
body
CHANGED
@@ -25,9 +25,9 @@
|
|
25
25
|
|
26
26
|
// textはSJISの"あ"
|
27
27
|
|
28
|
-
text =
|
28
|
+
text = convertSjisStrToUtf8Str(text) // => [63]
|
29
29
|
|
30
|
-
const
|
30
|
+
const convertSjisStrToUtf8Str = (sjisStr) => {
|
31
31
|
let ary = []
|
32
32
|
for (let index = 0; index < sjisStr.length; index++) {
|
33
33
|
ary.push(sjisStr.charCodeAt(index))
|
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -15,4 +15,23 @@
|
|
15
15
|
こんな風になってます。
|
16
16
|
これは一体どういった形式なのでしょうか。
|
17
17
|
|
18
|
-
textをこの形式に一旦変換してからEncoding.convertしてみようかなと思うのですが、それは可能なのでしょうか。
|
18
|
+
textをこの形式に一旦変換してからEncoding.convertしてみようかなと思うのですが、それは可能なのでしょうか。
|
19
|
+
|
20
|
+
-------------------
|
21
|
+
|
22
|
+
追記
|
23
|
+
|
24
|
+
```js
|
25
|
+
|
26
|
+
// textはSJISの"あ"
|
27
|
+
|
28
|
+
text = convertSjisSotrToUtf8Str(text) // => [63]
|
29
|
+
|
30
|
+
const convertSjisSotrToUtf8Str = (sjisStr) => {
|
31
|
+
let ary = []
|
32
|
+
for (let index = 0; index < sjisStr.length; index++) {
|
33
|
+
ary.push(sjisStr.charCodeAt(index))
|
34
|
+
}
|
35
|
+
return Encoding.convert(ary, 'UNICODE', 'SJIS')
|
36
|
+
}
|
37
|
+
```
|