Fixes #28507: Add ADR for Handling IO encoding in Rust modules - #6985
Merged
Conversation
Contributor
Author
|
PR updated with a new commit |
Fixes #28507: Add ADR for Handling IO encoding in Rust modules
m4rtinh4rt
marked this pull request as ready for review
March 11, 2026 10:08
amousset
reviewed
Mar 11, 2026
Contributor
Author
|
PR updated with a new commit |
…modules Fixes #28507: Add ADR for Handling IO encoding in Rust modules
Contributor
Author
|
PR updated with a new commit |
…n Rust modules Fixes #28507: Add ADR for Handling IO encoding in Rust modules
amousset
reviewed
Apr 2, 2026
|
|
||
| ## Consequences | ||
|
|
||
| The new functions must be used when performing I/O operations on files. |
Contributor
Author
There was a problem hiding this comment.
I think we want to use those functions everywhere to abstract the OS-specific logic (BOM vs. non-BOM) so we don’t have to repeat it in every module.
amousset
reviewed
Apr 2, 2026
amousset
reviewed
Apr 2, 2026
| - Takes as parameter the file path, the data string in UTF-8, and an enum specifying the target encoding. | ||
| - It supports writing files as UTF-8, UTF-8 with BOM and UTF-16 BOM LE. | ||
| - All writes to disk are atomic. | ||
| - On Windows, files written by this function include a BOM: |
Member
There was a problem hiding this comment.
why only on Windows? What would be the behavior on Linux?
Contributor
Author
There was a problem hiding this comment.
The current code in rudderc adds an UTF-8 BOM only for the Windows backend.
impl Backend for Windows {
fn generate(
&self,
technique: Technique,
resources: &Path,
_standalone: bool,
) -> Result<String> {
// Powershell requires a BOM added at the beginning of all files when using UTF8 encoding
// See https://docs.microsoft.com/en-us/windows/desktop/intl/using-byte-order-marks
// Bom for UTF-8 content, three bytes: EF BB BF https://en.wikipedia.org/wiki/Byte_order_mark
const UTF8_BOM: &[u8; 3] = &[0xef, 0xbb, 0xbf];
let mut with_bom = String::from_utf8(UTF8_BOM.to_vec()).unwrap();
with_bom.push_str(&Self::technique(technique, resources)?);
Ok(with_bom)
}
}It is not needed on Linux and could potentially break things.
Contributor
Author
|
PR updated with a new commit |
…oding in Rust modules Fixes #28507: Add ADR for Handling IO encoding in Rust modules
Contributor
Author
|
PR updated with a new commit |
… IO encoding in Rust modules Fixes #28507: Add ADR for Handling IO encoding in Rust modules
Contributor
Author
|
PR updated with a new commit |
…andling IO encoding in Rust modules Fixes #28507: Add ADR for Handling IO encoding in Rust modules
amousset
merged commit Apr 22, 2026
495a327
into
Normation:branches/rudder/9.0
14 of 22 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://issues.rudder.io/issues/28507