Back to index

im-sdk  12.3.91
Classes | Defines | Typedefs | Functions | Variables
symbol.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _SymbolGroup

Defines

#define SPECIAL_GROUP_NUM   8

Typedefs

typedef struct _SymbolGroup

Functions

Boolean composer_symbol_menu_lookup_start (int *number_of_candidates, UTFCHAR ***symbol_list_return)
Boolean composer_symbol_detail_lookup_start (int n_group_id, int *number_of_candidates, UTFCHAR ***symbol_list_return)

Variables

static char * symbol_group_names []
static char * special []

Class Documentation

struct _SymbolGroup

Definition at line 8 of file symbol.h.

Class Members
char * symbol_key
char * symbol_string

Define Documentation

#define SPECIAL_GROUP_NUM   8

Definition at line 4 of file symbol.h.


Typedef Documentation

typedef struct _SymbolGroup

Definition at line 6 of file symbol.h.


Function Documentation

Boolean composer_symbol_detail_lookup_start ( int  n_group_id,
int *  number_of_candidates,
UTFCHAR ***  symbol_list_return 
)

Definition at line 96 of file symbol.c.

{
  iconv_t cd;
  size_t iconv_return;
  /* not used
  char inbuffer[1024];
  */
  char outbuffer[1024];
  char *inptr, *outptr;
  size_t inlen, outlen;
  int i;

  char *ptr;

  assert (number_of_candidates != NULL);
  assert (symbol_list_return != NULL);
  assert ((n_group_id >= 0) && (n_group_id < g_symbol_table_size) );

  if (!g_symbol_table_size)
    composer_symbol_table_init ();

  if (n_group_id < 0 || n_group_id >= g_symbol_table_size)
    return False;

  cd = iconv_open ("UTF16", "UTF-8");
  if (cd == (iconv_t) -1){
    fprintf (stderr, "composer_symbol_menu_lookup_start: Iconv open failed\n");
    return False;
  }
  /*
    BEGIN: dummy conversion to flush BOM for the first time
  */
  
  inptr = special_symbols[0].symbol_key;
  outptr = outbuffer;
  inlen = strlen (special_symbols[0].symbol_key), outlen = sizeof (outbuffer);
  
  iconv (cd, &inptr, &inlen, &outptr, &outlen);
  
  /*
    END: dummy conversion to flush BOM for the first time
  */

  memset (outbuffer, 0, sizeof (outbuffer));
  
  inptr = special_symbols[n_group_id].symbol_string;
  outptr = outbuffer;
  inlen = strlen (special_symbols[n_group_id].symbol_string);
  outlen = sizeof (outbuffer);
  
  iconv_return = iconv (cd, &inptr, &inlen, &outptr, &outlen);
  if (iconv_return == (size_t) -1){
    /* if iconv fails, then I need to do some clean up
       before returns ...*/
    fprintf (stderr, "composer_symbol_detail_lookup_start : "
            "iconv failed\n");
    return False;
  }
  iconv_close (cd);
  
  *number_of_candidates = (sizeof (outbuffer) - outlen) / 2;
  *symbol_list_return =
    (UTFCHAR **) calloc (*number_of_candidates, sizeof (UTFCHAR *));
  
  for (i = 0, ptr = outbuffer
        ; i < *number_of_candidates ; i++, ptr += 2){
    (*symbol_list_return)[i] = (UTFCHAR *) calloc (2, sizeof (UTFCHAR));
    memcpy ((*symbol_list_return)[i], ptr, sizeof (UTFCHAR));
  }


  return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Boolean composer_symbol_menu_lookup_start ( int *  number_of_candidates,
UTFCHAR ***  symbol_list_return 
)

Definition at line 32 of file symbol.c.

{
  iconv_t cd;
  size_t iconv_return;
  /* not used
  char inbuffer[1024];
  */
  char outbuffer[1024];
  char *inptr, *outptr;
  size_t inlen, outlen;
  int i;

  assert (number_of_candidates != NULL);
  assert (symbol_list_return != NULL);

  if (!g_symbol_table_size)
    composer_symbol_table_init ();

  *number_of_candidates = g_symbol_table_size;
  *symbol_list_return = 
    (UTFCHAR **) calloc (*number_of_candidates, sizeof (UTFCHAR *));


  cd = iconv_open ("UTF16", "UTF-8");
  if (cd == (iconv_t) -1){
    fprintf (stderr, "composer_symbol_menu_lookup_start: Iconv open failed\n");
    return False;
  }
  /*
    BEGIN: dummy conversion to flush BOM for the first time
  */
  
  inptr = special_symbols[0].symbol_key, outptr = outbuffer;
  inlen = strlen (special_symbols[0].symbol_key), outlen = sizeof (outbuffer);
  
  iconv (cd, &inptr, &inlen, &outptr, &outlen);
  /*
    END: dummy conversion to flush BOM for the first time
  */
  
  for (i = 0 ; i < g_symbol_table_size; i++){
    inptr = special_symbols[i].symbol_key;
    outptr = outbuffer;
    inlen = strlen (special_symbols[i].symbol_key);
    outlen = sizeof (outbuffer);
    
    iconv_return = iconv (cd, &inptr, &inlen, &outptr, &outlen);

    if (iconv_return == (size_t) -1){
      continue;
    }
    
    (*symbol_list_return)[i] =
      (UTFCHAR *) calloc (sizeof (outbuffer) - outlen + 2, 1);
    
    memcpy ((*symbol_list_return)[i],
           outbuffer, sizeof (outbuffer) - outlen);
  }
  iconv_close (cd);
  return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char* special[] [static]

Definition at line 27 of file symbol.h.

char* symbol_group_names[] [static]
Initial value:
 {
    "특수문자1",
    "특수문자2",
    "로마문자용부호",
    "한글낱자",
    "로마숫자",
    "괘선조각",
    "각종 단위기호",
    "일본문자",
}

Definition at line 14 of file symbol.h.