Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One 16-bit unicode character can expand to up to four UTF-8 8-bit characters. #140

Closed
wants to merge 1 commit into from

Conversation

hselasky
Copy link

Fixes issue receiving SMS.

Signed-off-by: Hans Petter Selasky hps@selasky.org

…racters.

Signed-off-by: Hans Petter Selasky <hps@selasky.org>
@@ -403,7 +403,7 @@ EXPORT_DEF int at_parse_cmgr(char *str, size_t len, int *tpdu_type, char *sca, s
/* tpdu_parse_deliver sets chan_dongle_err */
return -1;
}
res = ucs2_to_utf8(msg16_tmp, res, msg, res * 2 + 2);
res = ucs2_to_utf8(msg16_tmp, res, msg, res * 4 + 2);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ 1 then?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why there was "+ 2". The "res * 4" already makes some assumptions about the buffer being passed is large enough. It doesn't hurt to have some extra space though ...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't hurt to have some extra space though ...

Extra space for a single NUL, if you're unsure: sure. But two extra spaces? That hurts, because it implies that that space is used for something.

The X*2+2 calculation looks like you're converting from 1-octet to 2-octet chars keeping room for a 2-octet NUL, so that made sense, even though it was wrong here. But I cannot think of a logical reason to do X*4+2.

@wdoekes
Copy link
Owner

wdoekes commented Apr 19, 2021

Closed by #131.

@wdoekes wdoekes closed this Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants