任意のPathに新しいファイルを作成するサンプル。
全角文字のようなマルチバイトの文字でも問題なく書き込みできた。
全角文字のようなマルチバイトの文字でも問題なく書き込みできた。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// --allow-write | |
const byteArray = new TextEncoder().encode('hello\r\n全角文字') | |
const file = await Deno.open('./test.txt', {write: true, create: true}) | |
await Deno.writeAll(file, byteArray) | |
Deno.close(file.rid) |
Manual | Deno - Read and write filesにもっとシンプルなサンプルがあることに、この投稿の作成中に気が付きました…。
0 件のコメント:
コメントを投稿