Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/3-web-servers/03-module/_samples/read-file-sync/main.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { readFileSync } from "fs";
console.log(readFileSync("sample.txt", "utf-8"));
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World
2 changes: 2 additions & 0 deletions docs/3-web-servers/03-module/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ console.log(readFileSync("sample.txt", "utf-8"));
Hello World
```

<ViewSource url={import.meta.url} path="_samples/read-file-sync" noCodeSandbox />

:::tip 文字コード

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