Module: kamailio
Branch: master
Commit: 61d91d7a684df73a328c3062653522a7439d4d61
URL:
https://github.com/kamailio/kamailio/commit/61d91d7a684df73a328c3062653522a…
Author: herlesupreeth <herlesupreeth(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-12-28T11:08:38+01:00
smsops: fix utf8 to ucs2 conversion
---
Modified: src/modules/smsops/smsops_impl.c
---
Diff:
https://github.com/kamailio/kamailio/commit/61d91d7a684df73a328c3062653522a…
Patch:
https://github.com/kamailio/kamailio/commit/61d91d7a684df73a328c3062653522a…
---
diff --git a/src/modules/smsops/smsops_impl.c b/src/modules/smsops/smsops_impl.c
index 703092542b0..9ed55328d8e 100644
--- a/src/modules/smsops/smsops_impl.c
+++ b/src/modules/smsops/smsops_impl.c
@@ -606,17 +606,17 @@ int utf8_to_ucs2(char *utf8, int utf8_len, char *ucs2, int
buffer_len)
} else if((utf8_char & 0xF0) == 0xE0) {
// Three-byte UTF-8 character
codepoint = ((utf8_char & 0x0F) << 12)
- | (((unsigned char)utf8[utf8_index + 1] & 0x3F) << 6)
- | ((unsigned char)utf8[utf8_index + 2] & 0x3F);
+ | (((unsigned char)utf8[utf8_index] & 0x3F) << 6)
+ | ((unsigned char)utf8[utf8_index + 1] & 0x3F);
utf8_index += 2;
tmp_buff[ucs2_index++] = (uint8_t)(codepoint >> 8);
tmp_buff[ucs2_index++] = (uint8_t)(codepoint & 0xFF);
} else if((utf8_char & 0xF8) == 0xF0) {
// Four-byte UTF-8 character
codepoint = ((utf8_char & 0x07) << 18)
- | (((unsigned char)utf8[utf8_index + 1] & 0x3F) << 12)
- | (((unsigned char)utf8[utf8_index + 2] & 0x3F) << 6)
- | ((unsigned char)utf8[utf8_index + 3] & 0x3F);
+ | (((unsigned char)utf8[utf8_index] & 0x3F) << 12)
+ | (((unsigned char)utf8[utf8_index + 1] & 0x3F) << 6)
+ | ((unsigned char)utf8[utf8_index + 2] & 0x3F);
utf8_index += 3;
// Convert to UCS-2 surrogate pair
codepoint -= 0x10000;