browndav
Joined: 04 Nov 2011 Posts: 5
|
Posted: Fri Jun 29, 2012 12:23 am Post subject: Is spider safe for SLV-encoded UCS-2 strings? |
|
|
Hi Pavel, All,
I have a quick test application. It displays a phrase written using devanagari script. It's on the UCS-2 0x9 page, and I have the string encoded as SLV per the other forum posts about using Arabic script. It displays just fine via display_text(), but when I use it as a menu item caption in spider(), it's truncated.
It's almost as if spider() is detecting the number of columns on the screen, and then limiting the displayed text to that many *bytes*. These are multibyte characters, so byte counting wouldn't yield a character length.
The following test case tries to display the same string twice -- first via a spider node, and then via display_text. Again, the display_text() version looks fine, but the menu version created by the spider library is truncated.
I'm using UCS-2 elsewhere in /direct/ calls to select_item(), and getting the correct, full, non-truncated strings. It's just spider that's giving me trouble w/ SLV-encoded UCS-2.
Can anyone please tell me what I'm doing wrong? Thanks so much.
Code: |
#include <bladox.h>
#include <string.h>
#include <stdlib.h>
#include <turbo/turbo.h>
/* Test case:
Testing UCS-2 character sets via STK display_text. */
lc_char PROGMEM lc_test_str[] = {
LC_UN("\x84\x08\x34\x80"
"\x9\x38\x9\x3e\x9\x2e\x9\x41\x9\x26\x9\x3e"
"\x9\x2f\x9\x3f\x9\x15\x0\x20\x9\x38\x9\x4d"
"\x9\x35\x9\x3e\x9\x38\x9\x4d\x9\x25\x9\x4d"
"\x9\x2f\x0\x20\x9\x38\x9\x30\x9\x4d\x9\x35\x9\x47\x0\x0")
LC_END
};
const u8 PROGMEM str[] = "String: ";
lc_char PROGMEM lc_topmenu_name[] = {
LC_UN("SIM Services")
LC_END
};
lc_char PROGMEM lc_menu_top[] = {
LC_UN("Charset Test")
LC_END
};
u8 menu_top_ctx (SCtx *ctx, u8 action)
{
return APP_OK;
}
SNodeP menu_top_n = { lc_test_str, menu_top_ctx };
u8 menu_test_ctx (SCtx *ctx, u8 action)
{
if (action == APP_ENTER) {
display_text(locale(lc_test_str), NULL);
}
return APP_OK;
}
SNodeP menu_test_n = {
lc_test_str, menu_test_ctx
};
SEdgeP menu_edges_p[] = {
{ &menu_top_n, &menu_test_n },
{ NULL, NULL }
};
void action_menu(void *data)
{
SCtx *c = spider_init();
c->n = (SNode *) &menu_top_n;
c->eP = (SEdgeP *) &menu_edges_p;
spider(c);
}
void turbo_handler(u8 action, void *data)
{
switch (action)
{
case ACTION_INSERT_MENU:
set_proc_8(PROC_8_LANGUAGE, LC_UNSPECIFIED);
set_menu_alpha(locale(lc_topmenu_name));
insert_menu(locale(lc_menu_top));
break;
case ACTION_MENU_SELECTION:
stk_thread(action_menu, data);
break;
default:
break;
}
}
| [/code] |
|