Skip to content

Commit 9a4c76d

Browse files
authored
Merge pull request hathach#2116 from dsugisawa-mixi/master
fix example of bare_api, check empty string
2 parents 6d03bb9 + 5e78f08 commit 9a4c76d

File tree

1 file changed

+1
-0
lines changed
  • examples/host/bare_api/src

1 file changed

+1
-0
lines changed

examples/host/bare_api/src/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ static int _count_utf8_bytes(const uint16_t *buf, size_t len) {
414414
}
415415

416416
static void print_utf16(uint16_t *temp_buf, size_t buf_len) {
417+
if ((temp_buf[0] & 0xff) == 0) return; // empty
417418
size_t utf16_len = ((temp_buf[0] & 0xff) - 2) / sizeof(uint16_t);
418419
size_t utf8_len = (size_t) _count_utf8_bytes(temp_buf + 1, utf16_len);
419420
_convert_utf16le_to_utf8(temp_buf + 1, utf16_len, (uint8_t *) temp_buf, sizeof(uint16_t) * buf_len);

0 commit comments

Comments
 (0)