Skip to content

言語: 文字 (char / rune) 型と UTF-8 セマンティクス RFC #106

Description

@ryuichi1208

目的

文字列のエンコーディングと「1 文字」の表現を決める。f-string (#18) / split / strip / find (#39) の戻り値・添字を確定するために必要。

現状

検討事項

  • エンコーディング: UTF-8 を確定 (Go / Rust と同じ)
  • char 型: rune = i32 (Go 風) or char = u32 codepoint (Rust)
  • 添字アクセス: str[i] はバイト位置か codepoint 位置か grapheme か
    • Rust は禁止 (bytes() / chars() を明示)
    • Go は byte index
    • Python は codepoint
  • イテレーション: for c in strc の型は?

提案 (drafting)

  • UTF-8 を確定
  • char (4-byte codepoint) を追加
  • str[i]禁止または警告(曖昧)→ 代わりに str_codepoints(s) / str_bytes(s) のような明示 API
  • for c in str は codepoint イテレーション

受け入れ条件

  • RFC ドキュメントを docs/specs/ に追加
  • char リテラル構文 ('a', '\u{1F600}') を決定
  • 既存 string API への影響を整理し移行プランを書く

関連

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:lang言語仕様・構文・型システムdocumentationImprovements or additions to documentationenhancementNew feature or requestpriority:medium実用化のために重要

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions