Skip to content

Encoding changed during format #3096

@rgilsimoes

Description

@rgilsimoes

Expected Behavior

I expect the file encoding to remain as UTF-8 after running ktlint with --format option regardless of the characters contained.

Observed Behavior

When the file contains some special characters ktlint changes the file encoding to ANSI

Steps to Reproduce

  1. Create a file in intellij with UTF-8 encoding
  2. Write a simple variable containing the following character §
  3. Close file
  4. Run ktlint on the file
  5. Open the file on intellij
  6. Wrong encoding is used, file is now ANSI encoded

Your Environment

  • Version of ktlint used: 1.2.1

  • Relevant parts of the .editorconfig settings:
    [{.kt,.kt.ftl}]
    max_line_length = off
    indent_style = space
    indent_size = 2
    ktlint_standard_trailing-comma-on-call-site = disabled
    ktlint_standard_trailing-comma-on-declaration-site = disabled
    ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 4
    ktlint_standard_no-empty-first-line-in-class-body = disabled
    ktlint_standard_property-naming = disabled
    ktlint_standard_value-argument-comment = disabled
    ktlint_standard_value-parameter-comment = disabled
    ktlint_standard_no-blank-line-in-list = disabled
    ktlint_standard_filename = disabled
    ij_kotlin_name_count_to_use_star_import = 999
    ij_kotlin_name_count_to_use_star_import_for_members = 999

  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): git-format-staged

  • Version of Gradle used (if applicable): N/A

  • Operating System and version: Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions