Skip to content
This repository was archived by the owner on Mar 10, 2022. It is now read-only.

Commit 38258ed

Browse files
borrrdenpasin
authored andcommitted
Fixes #1742 (emoji support) (#1745)
* Add test for Android emoji issue See #1742 * Add a test for round trip emoji It used to be fine because it was all modified UTF-8, but now need to test the conversion to normal UTF-8 and back. * Update LiteCore To get some tweaks to UTF-8 conversion
1 parent ac1fda7 commit 38258ed

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

android/CouchbaseLite/src/androidTest/java/com/couchbase/lite/JavaTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class JavaTest extends BaseTest {
3737
// https://github.com/couchbase/couchbase-lite-android/issues/1453
3838
@Test
3939
public void testFLEncode() throws LiteCoreException {
40+
testRoundTrip("Hello \uD83D\uDE3A World"); // 😺
4041
testRoundTrip(42L);
4142
testRoundTrip(Long.MIN_VALUE);
4243
testRoundTrip("Fleece");
@@ -49,6 +50,20 @@ public void testFLEncode() throws LiteCoreException {
4950
testRoundTrip(Math.PI);
5051
}
5152

53+
// https://github.com/couchbase/couchbase-lite-android/issues/1742
54+
@Test
55+
public void testDecodeEmoji() throws LiteCoreException {
56+
// 0000: 44 f0 9f 98…: "😺"
57+
// 0006: 80 03 : &"😺" (@0000)
58+
59+
byte[] realUtf8Data = new byte[] { (byte)0x44, (byte)0xF0, (byte)0x9F, (byte)0x98, (byte)0xBA,
60+
(byte)0x00, (byte)0x80, (byte)0x03 };
61+
FLValue flValue = FLValue.fromData(realUtf8Data);
62+
assertNotNull(flValue);
63+
Object obj = FLValue.toObject(flValue);
64+
assertEquals("\uD83D\uDE3A", obj);
65+
}
66+
5267
private void testRoundTrip(Object item) throws LiteCoreException {
5368
Encoder encoder = new Encoder();
5469
assertNotNull(encoder);

0 commit comments

Comments
 (0)