Skip to content

Commit

Permalink
fix(charset): read file with charset or as bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
juancgalvis committed Sep 19, 2024
1 parent 707a298 commit 334443a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/test/java/co/com/bancolombia/utils/FileUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ void readFile() throws IOException {
assertEquals("hello", response);
}

@Test
void readFileWithEncodingISO8859() throws IOException {
Project project =
ProjectBuilder.builder().withProjectDir(new File("src/test/resources")).build();
String response = FileUtils.readFile(project, "temp-iso-8859-1.txt");

assertEquals("¿cómo funcionará?", response);
}

@Test
void readFileWithOtherEncoding() throws IOException {
Project project =
ProjectBuilder.builder().withProjectDir(new File("src/test/resources")).build();
String response = FileUtils.readFile(project, "temp-other.txt");

assertEquals("*\u00ADx>e\u0001%ËØ´£/!vd\u0007", response);
}

@Test
void readFileFromResources() throws IOException {
DefaultResolver resolver = new DefaultResolver();
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/temp-iso-8859-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�c�mo funcionar�?
1 change: 1 addition & 0 deletions src/test/resources/temp-other.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*�x>e%�ش�/!vd

0 comments on commit 334443a

Please sign in to comment.