Add UTF-8 BOM to files written to S3/Minio#567
Open
DerkaouiAnas wants to merge 3 commits intofolio-org:masterfrom
Open
Add UTF-8 BOM to files written to S3/Minio#567DerkaouiAnas wants to merge 3 commits intofolio-org:masterfrom
DerkaouiAnas wants to merge 3 commits intofolio-org:masterfrom
Conversation
This change addresses issues with Excel not properly displaying Arabic characters in CSV files. By adding the BOM, we ensure that applications like Excel correctly recognize the file encoding as UTF-8.
khandramai
reviewed
Nov 12, 2024
| * @throws IOException - if an I/O error occurs | ||
| */ | ||
| public String write(String path, byte[] bytes, Map<String, String> headers) throws IOException { | ||
| byte[] bom = {(byte)0xEF, (byte)0xBB, (byte)0xBF}; |
Contributor
There was a problem hiding this comment.
Perhaps it makes sense to make this a constant instead of initializing the array in the method each time?
private static final byte[] UTF8_BOM = new byte[]{(byte) 0xEF, (byte) 0xBB, (byte) 0xBF};
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.
MODEXPW-508 - Add UTF-8 BOM to files written to S3/Minio
Purpose
The purpose of this change is to address issues with Excel not properly displaying Arabic characters in CSV files exported from our system. By adding a UTF-8 Byte Order Mark (BOM) to the beginning of these files, we ensure that applications like Excel correctly recognize the file encoding as UTF-8, thus displaying Arabic characters properly.
Related JIRA issue: https://issues.folio.org/browse/MODEXPW-508
Approach
To implement this change, we've modified the write method in our S3/Minio file writing utility. The approach involves: