diff options
author | nicm <nicm> | 2020-06-02 17:17:44 +0000 |
---|---|---|
committer | nicm <nicm> | 2020-06-02 17:17:44 +0000 |
commit | 7e501f1993cc1e4b8344643bcee449cc8c958d7e (patch) | |
tree | 8793341d4a7ae43fb212525a138ed5fdac488dd8 | |
parent | 822ee4e0a64cd27c4668aed53f1284b257612dcb (diff) | |
download | rtmux-7e501f1993cc1e4b8344643bcee449cc8c958d7e.tar.gz rtmux-7e501f1993cc1e4b8344643bcee449cc8c958d7e.tar.bz2 rtmux-7e501f1993cc1e4b8344643bcee449cc8c958d7e.zip |
UTF-8 keys need to be big endian so the size bits are at the top.
-rw-r--r-- | utf8.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -162,14 +162,14 @@ utf8_from_data(const struct utf8_data *ud, utf8_char *uc) m.data[1] = (offset >> 8) & 0xff; m.data[2] = (offset >> 16); } - *uc = m.uc; + *uc = htonl(m.uc); return (UTF8_DONE); fail: if (ud->width == 1) - *uc = utf8_space1.uc; + *uc = htonl(utf8_space1.uc); else - *uc = utf8_space2.uc; + *uc = htonl(utf8_space2.uc); return (UTF8_ERROR); } @@ -177,7 +177,7 @@ fail: void utf8_to_data(utf8_char uc, struct utf8_data *ud) { - union utf8_map m = { .uc = uc }; + union utf8_map m = { .uc = ntohl(uc) }; struct utf8_item *ui; u_int offset; @@ -210,7 +210,7 @@ utf8_build_one(char c, u_int width) if (width == 2) m.flags |= UTF8_FLAG_WIDTH2; - return (m.uc); + return (htonl(m.uc)); } /* Set a single character. */ |