toKotlinPackageSegment

Sanitizes the receiver so it can be used as a single Kotlin package segment.

Replaces every character that is not a valid Kotlin identifier part with _, and prefixes a leading _ when the first character would otherwise only be valid as an identifier part (e.g. a digit). Empty input becomes _.

Examples:

  • "radial-focal-tests" becomes "radial_focal_tests"

  • "my folder.v2" becomes "my_folder_v2"

  • "123abc" becomes "_123abc"