bladox.com Forum Index bladox.com
Turbo SIM Toolkit Adapter Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Is spider safe for SLV-encoded UCS-2 strings?

 
Post new topic   Reply to topic    bladox.com Forum Index -> Development
View previous topic :: View next topic  
Author Message
browndav



Joined: 04 Nov 2011
Posts: 5

PostPosted: Fri Jun 29, 2012 12:23 am    Post subject: Is spider safe for SLV-encoded UCS-2 strings? Reply with quote

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]
Back to top
View user's profile Send private message
pz



Joined: 12 Mar 2004
Posts: 1161

PostPosted: Mon Jul 02, 2012 11:51 am    Post subject: Reply with quote

Insert c->style |= SPIDER_STYLE_UCS2; after SCtx *c = spider_init();

Usually the max item len is 14 chars=bytes, for ucs2 (detected by this flag) it's 29 bytes.
Back to top
View user's profile Send private message
browndav



Joined: 04 Nov 2011
Posts: 5

PostPosted: Wed Jul 11, 2012 12:13 am    Post subject: Reply with quote

Thanks Pavel! This worked great.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    bladox.com Forum Index -> Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group