Skip to content

文字列定数を data section に UTF-8 で記録 #489

Description

@ufcpp

https://github.com/dotnet/roslyn/blob/main/docs/features/string-literals-data-section.md

文法上は何もなくて、「コンパイラーオプション次第でDLL中に文字列データを埋め込む方法が変わる」という話。
正直ブログに書くだけとかでもいいかも?

https://github.com/ufcpp/UfcppSample/tree/master/Demo/2025/StringInDataSection

主目的は
UserString セクションの方がサイズ上限厳しい
→ それで Razor コンパイル結果が引っ掛かった
→ Data セクションならまだ余裕があるからそっちに書き込みしようか
という話。

で、せっかくだから「UTF-8 で書こう」(u8 リテラルで既にやってるのでそれを流用)となり。
副次的に DLL サイズが小さくなりがちというメリットあり。
(「const string で埋め込むものって ASCII なことが多いし、UTF-8 の方が有利」というのが世の中の実情なので、現実的にはほぼ確実に DLL サイズ小さくなる。)

デメリットは「const string を読むときに UTF-8 → 16 の変換処理が1回かかる」みたいなコストあり。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions