mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-14 08:41:28 +00:00
fix unicode escaping for rtf file (#3609)
Signed-off-by: C1emency <> Signed-off-by: clkue <clemens_kuennemann@protonmail.com>
This commit is contained in:
@@ -76,8 +76,10 @@ public class ReadmeGenerator {
|
||||
input.chars().forEachOrdered(c -> {
|
||||
if (c < 128) {
|
||||
sb.append((char) c);
|
||||
} else if (c <= 0xFF) {
|
||||
sb.append("\\'").append(String.format("%02X", c));
|
||||
} else if (c < 0xFFFF) {
|
||||
sb.append("\\u").append(c);
|
||||
sb.append("\\uc1\\u").append(c);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ public class ReadMeGeneratorTest {
|
||||
@ParameterizedTest
|
||||
@CsvSource({ //
|
||||
"test,test", //
|
||||
"t\u00E4st,t\\u228st", //
|
||||
"t\uD83D\uDE09st,t\\u55357\\u56841st", //
|
||||
"t\u00E4st,t\\'E4st", //
|
||||
"t\uD83D\uDE09st,t\\uc1\\u55357\\uc1\\u56841st", //
|
||||
})
|
||||
public void testEscapeNonAsciiChars(String input, String expectedResult) {
|
||||
ReadmeGenerator readmeGenerator = new ReadmeGenerator(null);
|
||||
@@ -40,7 +40,7 @@ public class ReadMeGeneratorTest {
|
||||
MatcherAssert.assertThat(result, CoreMatchers.startsWith("{\\rtf1\\fbidis\\ansi\\uc0\\fs32"));
|
||||
MatcherAssert.assertThat(result, CoreMatchers.containsString("{\\sa80 Dear User,}\\par"));
|
||||
MatcherAssert.assertThat(result, CoreMatchers.containsString("{\\sa80 \\b please don't touch the \"d\" directory.}\\par "));
|
||||
MatcherAssert.assertThat(result, CoreMatchers.containsString("{\\sa80 Thank you for your cooperation \\u55357\\u56841}\\par"));
|
||||
MatcherAssert.assertThat(result, CoreMatchers.containsString("{\\sa80 Thank you for your cooperation \\uc1\\u55357\\uc1\\u56841}\\par"));
|
||||
MatcherAssert.assertThat(result, CoreMatchers.endsWith("}"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user