Skip to content

Commit 737b860

Browse files
committed
fix(jackson): decode short strings as UTF-8
1 parent a1b994c commit 737b860

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎msgpack-jackson/src/main/java/org/msgpack/jackson/dataformat/MessagePackParser.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ private String unpackString(MessageUnpacker messageUnpacker) throws IOException
174174
return new String(tempChars, 0, strLen);
175175
}
176176
else {
177-
return new String(tempBytes, 0, strLen);
177+
return new String(tempBytes, 0, strLen, StandardCharsets.UTF_8);
178178
}
179179
}
180180
else {

‎msgpack-jackson/src/test/java/org/msgpack/jackson/dataformat/MessagePackDataformatForPojoTest.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ public void testStrings()
9494
assertEquals(stringPojo.longMultiByte, value.longMultiByte);
9595
}
9696

97+
@Test
98+
public void testUnicodeStringRoundTrip()
99+
throws IOException
100+
{
101+
String original = "çÇğĞıİöÖşŞüÜ";
102+
byte[] bytes = objectMapper.writeValueAsBytes(original);
103+
String value = objectMapper.readValue(bytes, String.class);
104+
assertEquals(original, value);
105+
}
106+
97107
@Test
98108
public void testUsingCustomConstructor()
99109
throws IOException

0 commit comments

Comments
 (0)