情報アイコン
情報 / Info
当サイトは、Typst GmbHの許諾を得て、日本語コミュニティ「Typst Japan Community」がTypst v0.13.1の公式ドキュメントを翻訳したものです。誤訳や古い情報が含まれている可能性があるため、公式ドキュメントとの併用を推奨します。翻訳の改善やサイトの機能向上について、GitHubでのIssueやPull Requestを歓迎します。コミュニティにご興味のある方はDiscordサーバー「くみはんクラブ」にぜひご参加ください。
This site provides a Japanese translation of the Typst v0.13.1 documentation maintained by the "Typst Japan Community" with permission from Typst GmbH. We recommend using this alongside the official documentation. We welcome contributions through Issues and Pull Requests on our GitHub repository for both translation improvements and website enhancements. Feel free to join our Discord server "Kumihan Club".
言語アイコン
未翻訳

このページはまだ翻訳されていません。原文の内容が表示されています。

bytes

A sequence of bytes.

This is conceptually similar to an array of integers between 0 and 255, but represented much more efficiently. You can iterate over it using a for loop.

You can convert

  • a string or an array of integers to bytes with the bytes constructor
  • bytes to a string with the str constructor, with UTF-8 encoding
  • bytes to an array of integers with the array constructor

When reading data from a file, you can decide whether to load it as a string or as raw bytes.

#bytes((123, 160, 22, 0)) \
#bytes("Hello 😃")

#let data = read(
  "rhino.png",
  encoding: none,
)

// Magic bytes.
#array(data.slice(0, 4)) \
#str(data.slice(1, 4))
Preview

コンストラクタ
ヘルプアイコン

Converts a value to bytes.

  • Strings are encoded in UTF-8.
  • Arrays of integers between 0 and 255 are converted directly. The dedicated byte representation is much more efficient than the array representation and thus typically used for large byte buffers (e.g. image data).
#bytes("Hello 😃") \
#bytes((123, 160, 22, 0))
Preview

value
Required
ヘルプアイコン
Positional
ヘルプアイコン

The value that should be converted to bytes.

定義
ヘルプアイコン

len

The length in bytes.

self.len(
)->

at

Returns the byte at the specified index. Returns the default value if the index is out of bounds or fails with an error if no default value was specified.

self.at()->
any

index
Required
ヘルプアイコン
Positional
ヘルプアイコン

The index at which to retrieve the byte.

default
any

A default value to return if the index is out of bounds.

slice

Extracts a subslice of the bytes. Fails with an error if the start or end index is out of bounds.

self.slice()->

start
Required
ヘルプアイコン
Positional
ヘルプアイコン

The start index (inclusive).

end
Positional
ヘルプアイコン

The end index (exclusive). If omitted, the whole slice until the end is extracted.

デフォルト値:

none

count

The number of items to extract. This is equivalent to passing start + count as the end position. Mutually exclusive with end.

検索