From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 01/10] stkutil: display text attributes as html
Date: Thu, 01 Jul 2010 18:12:11 -0500 [thread overview]
Message-ID: <4C2D20CB.4000405@gmail.com> (raw)
In-Reply-To: <1277998285-30207-2-git-send-email-kristen@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 1988 bytes --]
Hi Kristen,
> +#define STK_TEXT_FORMAT_INIT -1
I'd really prefer 0xffff here
> +char *stk_text_to_html(const char *text, int text_len,
> + const unsigned char *attrs, int attrs_len)
> +{
I think that text_len is not required, this function can figure it out
itself by using strlen or friends.
> + GString *string = g_string_sized_new(text_len + 1);
> + int *formats;
> + int pos, i, j, attr, prev_attr;
> + guint8 start, end, code, color, len, align;
> +
> + formats = g_try_malloc0(sizeof(int) * (text_len + 1));
Why are you allocating ints instead of shorts?
Also, you have to be really careful here. Text inside oFono is
understood to be UTF8 always. The formats array should be allocated
according to how many UTF8 characters there are, not how many bytes
there are. GSM characters can be represented by up to 3 byte UTF8
chars. UCS2 characters can be represented by up to 4 byte UTF8 chars.
Also please realize that is is not required unless you modify the
signature of attrs to be something other than unsigned char (limited to
max=255)
> + if (formats == NULL)
> + return NULL;
> +
> + /* we will need formatting at the position beyond the last char */
> + for (i = 0; i <= text_len; i++)
> + formats[i] = STK_TEXT_FORMAT_INIT;
> +
> + for (i = 0; i+3 < attrs_len; i += 4) {
> + start = attrs[i];
> + len = attrs[i + 1];
> + code = attrs[i + 2];
> +
> + if (i + 3 < attrs_len)
> + color = attrs[i + 3];
> + else
> + color = 0;
My suggestion is to generalize this function to support both EMS
messages and STK strings. We can treat attrs as:
unsigned short *attrs, unsigned short len where len = number of
quadruples. See the earlier thread for details.
The reason for using shorts is to support larger EMS message sizes.
> +
> + for (pos = 0; pos <= text_len; pos++) {
And again here you have to be careful and use UTF8 character lengths,
not simple ASCII lengths.
Regards,
-Denis
next prev parent reply other threads:[~2010-07-01 23:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-01 15:31 [PATCH 00/10] html text attributes patches Kristen Carlson Accardi
2010-07-01 15:31 ` [PATCH 01/10] stkutil: display text attributes as html Kristen Carlson Accardi
2010-07-01 23:12 ` Denis Kenzior [this message]
2010-07-01 15:31 ` [PATCH 02/10] test-stkutil: add unit test for html text attributes Kristen Carlson Accardi
2010-07-01 15:31 ` [PATCH 03/10] test-stkutil: add html attribute test for Display Text tests Kristen Carlson Accardi
2010-07-01 15:31 ` [PATCH 04/10] test-stkutil: add html attribute tests for get_inkey_test Kristen Carlson Accardi
2010-07-01 15:31 ` [PATCH 05/10] test-stkutil: add html attribute tests for get_input_test Kristen Carlson Accardi
2010-07-01 15:31 ` [PATCH 06/10] test-stkutil: add html attribute tests for play_tone_test Kristen Carlson Accardi
2010-07-01 15:31 ` [PATCH 07/10] test-stkutil: add html attribute test for setup_menu_test Kristen Carlson Accardi
2010-07-01 15:31 ` [PATCH 08/10] test-stkutil: add html attribute test for select_item_test Kristen Carlson Accardi
2010-07-01 15:31 ` [PATCH 09/10] test-stkutil: add html attribute tests for setup idle mode tests Kristen Carlson Accardi
2010-07-01 15:31 ` [PATCH 10/10] test-stkutil: add html_attr_test for special chars Kristen Carlson Accardi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C2D20CB.4000405@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.