Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages | Examples

String Formats, Localization


Detailed Description

All GSM codings are supported: 7bit packed/unpacked, 8bit and UCS2 16 bit.

To convert various codings (ISO-8859-1 and UTF-8) use gsmtstr utility available at http://www.bladox.com/pub/gsmtstr-1.0.tar.gz

String Formats

The text strings can be coded in two ways:

strlen()

Built-in strlen() is NOT standard POSIX compliant strlen. It is modified to work with both codings and returns:
  1. ALPHA coding, default GSM alphabet - the length of the string not including the terminating `\0' character
  2. ALPHA coding, UCS2, all 3 variants - the number of bytes necessary to perform complete copy of string (i.e. memcpy(to, src, strlen(src)) makes identical copy of src).
  3. STRING_SLV - the number of bytes of Value.

ALPHA coding

ALPHA coded strings of be either unpacked, 7bit, default GSM alphabet, \0 terminated character arrays (i.e. similar to standard char *), or 16 bit UCS2 coded character arrays. In the case of UCS2 the Ref. 11.11 describes 3 different variants.

Attention:
UCS2 strings are not \0 terminated.

STRING_SLV coding

STRING_SLV coded string format is:

string_slv.png

The VALUE can be packed or unpacked (depending on DCS).

Attention:
LENGTH is the number of characters - not bytes, i.e. the number of septets in case of 7b DCS, and the number of octets in case of 8b and 16b DCS.

Localization

Turbo provides localization in a way that you can insert several variants on one string in your code and based on the user preferred language desired variant is used. You can also use the localized lists.

The typical usage is:

lc_char PROGMEM lc_My_Text[]={
        LC_EN("My Text")
        LC_CZ("Muj Text")
        LC_END
};

foo()
{
u8 *text = locale(lc_My_Text);
...
}
Attention:
The lc_My_Text must end with LC_END.
Use config.h
Because it can be wasting of memory to insert all language variants into one binary, with the help of config.h and commenting out the LC_language defines you can have one source but different language binary variants.

Localized list
Example of localized list usage:
#ifdef CONFIG_LANG_EN
u8 PROGMEM t_yes_en[]="Yes";
u8 PROGMEM t_no_en[]="No";

const u8 * PROGMEM l_yesno_en[]=
{
                t_yes_en,
                t_no_en
};
#endif

#ifdef CONFIG_LANG_CZ
u8 PROGMEM t_yes_cz[]="Ano";
u8 PROGMEM t_no_cz[]="Ne";

const u8 * PROGMEM l_yesno_cz[]=
{
                t_yes_cz,
                t_no_cz
};
#endif

lc_list PROGMEM lc_YesNo[]={
        LC_EN_LIST(l_yesno_en)
        LC_CZ_LIST(l_yesno_cz)
        LC_END_LIST
};

foo()
{
select_item (2, locale_list(lc_YesNo), ...);
}

Data Structures

Defines

Typedefs

Functions


Define Documentation

#define LC_AR  ) 
 

Localized string, Arabic, for coding Ref. 03.38.

#define LC_AR_LIST  ) 
 

Localized array of strings, Arabic, for coding Ref. 03.38.

#define LC_CZ  ) 
 

Localized string, Czech, for coding Ref. 03.38.

Examples:
certs.c, mc.c, pos.c, and test_img.c.

#define LC_CZ_LIST  ) 
 

Localized array of strings, Czech, for coding Ref. 03.38.

#define LC_DE  ) 
 

Localized string, German, for coding Ref. 03.38.

#define LC_DE_LIST  ) 
 

Localized array of strings, German, for coding Ref. 03.38.

#define LC_DK  ) 
 

Localized string, Danish, for coding Ref. 03.38.

#define LC_DK_LIST  ) 
 

Localized array of strings, Danish, for coding Ref. 03.38.

#define LC_EL  ) 
 

Localized string, Greek, for coding Ref. 03.38.

#define LC_EL_LIST  ) 
 

Localized array of strings, Greek, for coding Ref. 03.38.

#define LC_EN  ) 
 

Localized string, English, for coding Ref. 03.38.

Examples:
braled.c, braping.c, callback.c, certs.c, fake_sim.c, mc.c, pos.c, sysinfo.c, test_idle.c, test_img.c, test_prot_mem.c, test_refresh.c, and tsmsacl.c.

#define LC_EN_LIST  ) 
 

Localized array of strings, English, for coding Ref. 03.38.

#define LC_END
 

Terminator of lc_char[].

#define LC_END_LIST
 

Terminator of lc_list[].

#define LC_ES  ) 
 

Localized string, Spanish, for coding Ref. 03.38.

#define LC_ES_LIST  ) 
 

Localized array of strings, Spanish, for coding Ref. 03.38.

#define LC_FI  ) 
 

Localized string, Finnish, for coding Ref. 03.38.

#define LC_FI_LIST  ) 
 

Localized array of strings, Finnish, for coding Ref. 03.38.

#define LC_FR  ) 
 

Localized string, French, for coding Ref. 03.38.

#define LC_FR_LIST  ) 
 

Localized array of strings, French, for coding Ref. 03.38.

#define LC_HE  ) 
 

Localized string, Hebrew, for coding Ref. 03.38.

#define LC_HE_LIST  ) 
 

Localized array of strings, Hebrew, for coding Ref. 03.38.

#define LC_HU  ) 
 

Localized string, Hungarian, for coding Ref. 03.38.

#define LC_HU_LIST  ) 
 

Localized array of strings, Hungarian, for coding Ref. 03.38.

#define LC_IS  ) 
 

Localized string, Icelandic, for coding Ref. 03.38.

#define LC_IS_LIST  ) 
 

Localized array of strings, Icelandic, for coding Ref. 03.38.

#define LC_IT  ) 
 

Localized string, Italian, for coding Ref. 03.38.

#define LC_IT_LIST  ) 
 

Localized array of strings, Italian, for coding Ref. 03.38.

#define LC_NL  ) 
 

Localized string, Ref. 03.38

#define LC_NL_LIST  ) 
 

Localized array of strings, Dutch, for coding Ref. 03.38.

#define LC_NO  ) 
 

Localized string, Norwegian, for coding Ref. 03.38.

#define LC_NO_LIST  ) 
 

Localized array of strings, Norwegian, for coding Ref. 03.38.

#define LC_PL  ) 
 

Localized string, Polish, for coding Ref. 03.38.

#define LC_PL_LIST  ) 
 

Localized array of strings, Polish, for coding Ref. 03.38.

#define LC_PT  ) 
 

Localized string, Portuguese, for coding Ref. 03.38.

#define LC_PT_LIST  ) 
 

Localized array of strings, Portuguese, for coding Ref. 03.38.

#define LC_RU  ) 
 

Localized string, Russian, for coding Ref. 03.38.

Examples:
hello_world_ucs2.c.

#define LC_RU_LIST  ) 
 

Localized array of strings, Russian, for coding Ref. 03.38.

#define LC_SE  ) 
 

Localized string, Swedish, for coding Ref. 03.38.

#define LC_SE_LIST  ) 
 

Localized array of strings, Swedish, for coding Ref. 03.38.

#define LC_TR  ) 
 

Localized string, Turkish, for coding Ref. 03.38.

#define LC_TR_LIST  ) 
 

Localized array of strings, Turkish, for coding Ref. 03.38.

#define LC_UN  ) 
 

Localized string, Unspecified/Universal, for coding Ref. 03.38.

Examples:
calc.c, and fake_sim.c.

#define LC_UN_LIST  ) 
 

Localized array of strings, Unspecified/Universal, for coding Ref. 03.38.

#define STRING_SLV
 

Indicates that data are stored in [STYLE][LEN][VALUE].

See also:
STRING_SLV coding


Typedef Documentation

typedef struct _lc_char lc_char
 

Used for string localization.

See also:
locale()

typedef struct _lc_list lc_list
 

Used for list ocalization.

See also:
locale_list()


Function Documentation

u8* locale const lc_char str  ) 
 

Returns string from lc_char array following the user selected language. If not found the first string is returned.

lc_char PROGMEM lc_My_Text[]={
        LC_EN("My Text")
        LC_CZ("Muj Text")
        LC_END
};

foo()
{
u8 *text = locale(lc_My_Text);
...
}

Parameters:
str pointer on lc_char array. Can be from PROGMEM only
Examples:
hello_world_ucs2.c.

u8* locale_list const lc_list list  ) 
 

Localized list - based on user preferred language desired language list is used.

#ifdef CONFIG_LANG_EN
u8 PROGMEM t_yes_en[]="Yes";
u8 PROGMEM t_no_en[]="No";

const u8 * PROGMEM l_yesno_en[]=
{
                t_yes_en,
                t_no_en
};
#endif

#ifdef CONFIG_LANG_CZ
u8 PROGMEM t_yes_cz[]="Ano";
u8 PROGMEM t_no_cz[]="Ne";

const u8 * PROGMEM l_yesno_cz[]=
{
                t_yes_cz,
                t_no_cz
};
#endif

lc_list PROGMEM lc_YesNo[]={
        LC_EN_LIST(l_yesno_en)
        LC_CZ_LIST(l_yesno_cz)
        LC_END_LIST
};

foo()
{
select_item (2, locale_list(lc_YesNo), ...);
}

Parameters:
list pointer on lc_list array. Can be from PROGMEM only.
See also:
select_item()


Copyright © 2004-2006 BLADOX
Turbo version 1.2