Skip to content

Commit e807a28

Browse files
authored
Merge pull request #371 from ut-code/add-readfilesync-codesandbox
Add CodeSandbox for `fs.readFileSync`
2 parents 4418e4f + 5a197a1 commit e807a28

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { readFileSync } from "fs";
2+
console.log(readFileSync("sample.txt", "utf-8"));
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello World

docs/3-web-servers/03-module/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ console.log(readFileSync("sample.txt", "utf-8"));
156156
Hello World
157157
```
158158

159+
<ViewSource url={import.meta.url} path="_samples/read-file-sync" noCodeSandbox />
160+
159161
:::tip 文字コード
160162

161163
**文字コード**とは、文字のコンピューターによる表現です。`UTF-8``Shift_JIS` などさまざまな方式が定義されていますが、現在では通常 `UTF-8` を選んでおけば問題ありません。間違った方式を選んでしまうと、意図と異なる文字として解釈されてしまう現象 (**文字化け**)が起こります。

0 commit comments

Comments
 (0)