Beispiel #1
0
static void
convert_cat(String *cap, char *s, Config *c, int maxlen)
{
  int res;

  if (config_get_boolean(c, "/enfle/plugins/ui/normal/filename_code_conversion", &res)) {
    char **froms = config_get_list(c, "/enfle/plugins/ui/normal/filename_code_from", &res);
    char *to = config_get_str(c, "/enfle/plugins/ui/normal/filename_code_to");
    char *from;
    int i = 0;

    if (res && to) {
      while ((from = froms[i++])) {
	char *tmp;

	//debug_message_fnc("%s->%s: %s\n", from, to, s);
	if ((res = converter_convert(s, &tmp, strlen(s), from, to)) < 0)
	  continue;
	if (maxlen)
	  string_ncat(cap, tmp, maxlen);
	else
	  string_cat(cap, tmp);
	free(tmp);
	return;
      }
    }
  }

  if (maxlen > 0)
    string_ncat(cap, s, maxlen);
  else
    string_cat(cap, s);
}
Beispiel #2
0
size_t opencc_convert(opencc_t t_opencc, ucs4_t ** inbuf, size_t * inbuf_left,
                      ucs4_t ** outbuf, size_t * outbuf_left)
{
    if (!lib_initialized)
        lib_initialize();

    opencc_desc * opencc = (opencc_desc *) t_opencc;

    size_t retval = converter_convert
                    (opencc->converter, inbuf, inbuf_left, outbuf, outbuf_left);

    if (retval == (size_t) -1)
        errnum = OPENCC_ERROR_CONVERTER;

    return retval;
}