jenkinsci / jenkinsci/workflow-basic-steps-plugin

[JENKINS-58835] recognize file's encodings

Open
#494 1 comment 0 reactions 0 assignees View on GitHub
component:workflow-basic-steps-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
73
Forks
129
PR merge metrics
No merged PRs in 30d

Description

It would be nice if the readFile basic step could recognize the file's encoding.  (Writing a file with writeFile can store a BOM at the beginning to help in recognizing the character set later, but this must be only a non-default option to preserve backward compatibility with earlier groovy code reading the created files.  This agrees with a rule of thumb "accept liberally, produce conservatively").

There is no need to reinvent the wheel.  Using (and white-listing) groovy.util.CharsetToolkit can make this easy.

 

https://github.com/groovy/groovy-core/blob/GROOVY_2_4_X/src/main/groovy/util/CharsetToolkit.java#L388

 

http://docs.groovy-lang.org/latest/html/api/groovy/util/CharsetToolkit.html#getReader()

 

https://github.com/jenkinsci/workflow-basic-steps-plugin/blob/workflow-basic-steps-2.18/src/main/java/org/jenkinsci/plugins/workflow/steps/ReadFileStep.java

 

---
Originally reported by ilatypov, imported from: recognize file's encodings


  • status: Open
  • priority: Minor
  • component(s): workflow-basic-steps-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 20251215-220547

Raw content of original issue

It would be nice if the readFile basic step could recognize the file's encoding.  (Writing a file with writeFile can store a BOM at the beginning to help in recognizing the character set later, but this must be only a non-default option to preserve backward compatibility with earlier groovy code reading the created files.  This agrees with a rule of thumb "accept liberally, produce conservatively").

There is no need to reinvent the wheel.  Using (and white-listing) groovy.util.CharsetToolkit can make this easy.

 

https://github.com/groovy/groovy-core/blob/GROOVY_2_4_X/src/main/groovy/util/CharsetToolkit.java#L388

 

http://docs.groovy-lang.org/latest/html/api/groovy/util/CharsetToolkit.html#getReader()

 

https://github.com/jenkinsci/workflow-basic-steps-plugin/blob/workflow-basic-steps-2.18/src/main/java/org/jenkinsci/plugins/workflow/steps/ReadFileStep.java

 

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.