Beispiel #1
0
void
send_edge_data_changed(Network *network, const GraphEdge *edge, gpointer user_data) {
    UiConnection *ui = (UiConnection *)user_data;

     // FIXME: remove once noflo-ui no longer needs it
    gchar *src_port = g_utf8_strup(edge->src_port, -1);
    gchar *tgt_port = g_utf8_strup(edge->tgt_port, -1);
    gchar *edge_id = g_strdup_printf("%s() %s -> %s %s()",
                                     edge->src_name, src_port,
                                     tgt_port, edge->tgt_name);
    g_free(src_port);
    g_free(tgt_port);

    gchar *url = ui_get_process_url(ui, network, edge->src_name);
    JsonObject *payload = graph_edge_to_json(edge);
    json_object_set_string_member(payload, "graph", network->graph->id);
    json_object_set_string_member(payload, "id", edge_id);

    JsonObject *data = json_object_new();
    json_object_set_object_member(payload, "data", data);
    json_object_set_string_member(data, "url", url);
    json_object_set_string_member(data, "type", "previewurl");

    g_free(url);

    if (ui->connection) {
        send_response(ui->connection, "network", "data", payload);
    }
}
Beispiel #2
0
static gboolean
part_list_filter_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
	char *part_name;
	const char *s;
	// Auxiliary parameters shall keep their number in upcase
	char *comp1, *comp2;
	Browser *br = (Browser *)data;

	s = gtk_entry_get_text (GTK_ENTRY (br->filter_entry));
	// Without filter, the part is shown
	if (s == NULL) return TRUE;
	if (br->filter_len == 0) return TRUE;

	gtk_tree_model_get (model, iter, 0, &part_name, -1);

	if (part_name) {
		comp1 = g_utf8_strup (s, -1);
		comp2 = g_utf8_strup (part_name, -1);

		if (g_strrstr (comp2, comp1)) {
			g_free (comp1);
			g_free (comp2);
			return TRUE;
		}

		g_free (comp1);
		g_free (comp2);
	}
	return FALSE;
}
Beispiel #3
0
static int
plugin_compare(PurplePlugin *p1, PurplePlugin *p2)
{
	char *s1 = g_utf8_strup(p1->info->name, -1);
	char *s2 = g_utf8_strup(p2->info->name, -1);
	int ret = g_utf8_collate(s1, s2);
	g_free(s1);
	g_free(s2);
	return ret;
}
static gchar *
xkl_create_description_from_list (const XklConfigItem * item,
				  const XklConfigItem * subitem,
				  const gchar * prop_name,
				  const gchar *
				  (*desc_getter) (const gchar * code))
{
	gchar *rv = NULL, *code = NULL;
	gchar **list = NULL;
	const gchar *desc;

	if (subitem != NULL)
		list =
		    (gchar
		     **) (g_object_get_data (G_OBJECT (subitem),
					     prop_name));
	if (list == NULL || *list == 0)
		list =
		    (gchar
		     **) (g_object_get_data (G_OBJECT (item), prop_name));

	/* First try the parent id as such */
	desc = desc_getter (item->name);
	if (desc != NULL) {
		rv = g_utf8_strup (desc, -1);
	} else {
		code = g_utf8_strup (item->name, -1);
		desc = desc_getter (code);
		if (desc != NULL) {
			rv = g_utf8_strup (desc, -1);
		}
		g_free (code);
	}

	if (list == NULL || *list == 0)
		return rv;

	while (*list != 0) {
		code = *list++;
		desc = desc_getter (code);
		if (desc != NULL) {
			gchar *udesc = g_utf8_strup (desc, -1);
			if (rv == NULL) {
				rv = udesc;
			} else {
				gchar *orv = rv;
				rv = g_strdup_printf ("%s %s", rv, udesc);
				g_free (orv);
				g_free (udesc);
			}
		}
	}
	return rv;
}
Beispiel #5
0
static int
plugin_compare(PurplePlugin *p1, PurplePlugin *p2)
{
	char *s1 = g_utf8_strup(purple_plugin_info_get_name(purple_plugin_get_info(p1)), -1);
	char *s2 = g_utf8_strup(purple_plugin_info_get_name(purple_plugin_get_info(p2)), -1);
	int ret = g_utf8_collate(s1, s2);
	g_free(s1);
	g_free(s2);

	return ret;
}
Beispiel #6
0
/*
 * meh_widget_text_reload writes the text on a texture and store it in the WidgetText.
 */
void meh_widget_text_reload(Window* window, WidgetText* text) {
	if (text->texture != NULL) {
		SDL_DestroyTexture(text->texture);
	}

	SDL_Color color = {
		text->r.value,
		text->g.value,
		text->b.value,
		text->a.value,
	};

	gchar* to_render = text->text;
	if (text->uppercase) {
		to_render = g_utf8_strup(text->text, -1);
	}

	/* Render the text on a texture. */
	if (!text->multi) {
		text->texture = meh_window_render_text_texture(window, text->font, to_render, color, -1.0f);
	} else {
		text->texture = meh_window_render_text_texture(window, text->font, to_render, color, meh_window_convert_width(window, text->w));
	}

	if (text->uppercase) {
		g_free(to_render);
	}

	SDL_QueryTexture(text->texture, NULL, NULL, &text->tex_w, &text->tex_h);
	g_debug("Texture for text %s loaded (%dx%d).", text->text, text->tex_w, text->tex_h);

	/* restart the movement infos */
	meh_widget_text_reset_move(text);
}
Beispiel #7
0
static void
doc_code_selection(Tdocument * doc, Treplace_mode mode)
{
	gint start, end;
	if (doc_get_selection(doc, &start, &end)) {
		gchar *inbuf, *outbuf = NULL;

		inbuf = doc_get_chars(doc, start, end);
		switch (mode) {
		case mode_urlencode:
			outbuf = g_uri_escape_string(inbuf, NULL, FALSE);
			break;
		case mode_urldecode:
			outbuf = g_uri_unescape_string(inbuf, NULL);
			break;
		case mode_tolowercase:
			if (inbuf)
				outbuf = g_utf8_strdown(inbuf, -1);
			break;
		case mode_touppercase:
			if (inbuf)
				outbuf = g_utf8_strup(inbuf, -1);
			break;
		}
		g_free(inbuf);
		if (outbuf) {
			doc_replace_text(doc, outbuf, start, end);
			g_free(outbuf);
		}
	}
}
Beispiel #8
0
static gchar* enchant_utf8_strtitle(const gchar*str, gssize len)
{
	gunichar title_case_char;
	gchar* result;
	gchar* upperStr, * upperTail, * lowerTail;
	gchar title_case_utf8[7];
	gint utf8len;

	upperStr = g_utf8_strup(str, len); /* for locale sensitive casing */

	title_case_char = g_unichar_totitle(g_utf8_get_char(upperStr));

	utf8len = g_unichar_to_utf8(title_case_char, title_case_utf8);
	title_case_utf8[utf8len] = '\0';

	upperTail = g_utf8_next_char(upperStr);
	lowerTail = g_utf8_strdown(upperTail, -1);

	result = g_strconcat(title_case_utf8, 
						 lowerTail, 
						 NULL);

	g_free(upperStr);
	g_free(lowerTail);

	return result;
}
Beispiel #9
0
static char *
userinfo_hash(PurpleAccount *account, const char *who)
{
	char key[256];
	g_snprintf(key, sizeof(key), "%s - %s", purple_account_get_username(account), purple_normalize(account, who));
	return g_utf8_strup(key, -1);
}
static void
xkb_layout_filter_changed (GtkBuilder * chooser_dialog)
{
	GtkTreeModelFilter *filtered_model =
	    GTK_TREE_MODEL_FILTER (gtk_builder_get_object (chooser_dialog,
							   "filtered_layout_list_model"));
	GtkWidget *xkb_layout_filter = CWID ("xkb_layout_filter");
	const gchar *pattern =
	    gtk_entry_get_text (GTK_ENTRY (xkb_layout_filter));
	gchar *upattern = g_utf8_strup (pattern, -1);

	if (!g_strcmp0 (pattern, "")) {
		g_object_set (G_OBJECT (xkb_layout_filter),
			      "secondary-icon-name", "edit-find-symbolic",
			      "secondary-icon-activatable", FALSE,
			      "secondary-icon-sensitive", FALSE, NULL);
	} else {
		g_object_set (G_OBJECT (xkb_layout_filter),
			      "secondary-icon-name", "edit-clear-symbolic",
			      "secondary-icon-activatable", TRUE,
			      "secondary-icon-sensitive", TRUE, NULL);
	}

	if (search_pattern_list != NULL)
		g_strfreev (search_pattern_list);

	search_pattern_list = g_strsplit (upattern, " ", -1);
	g_free (upattern);

	gtk_tree_model_filter_refilter (filtered_model);
}
Beispiel #11
0
void
on_protocol_edit_ok_clicked (GtkButton * button, gpointer user_data)
{
  gchar *proto_string;
  GtkTreePath *gpath = NULL;
  GtkTreeViewColumn *gcol = NULL;
  GtkTreeIter it;
  GtkComboBoxEntry *cbox;
  EATreePos ep;
  if (!get_color_store (&ep))
    return;

  /* gets the row (path) at cursor */
  gtk_tree_view_get_cursor (ep.gv, &gpath, &gcol);
  if (!gpath)
    return;			/* no row selected */

  if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (ep.gs), &it, gpath))
    return;			/* path not found */

  cbox = GTK_COMBO_BOX_ENTRY(glade_xml_get_widget (appdata.xml, "protocol_entry"));
  proto_string = gtk_combo_box_get_active_text(GTK_COMBO_BOX(cbox));
  proto_string = g_utf8_strup (proto_string, -1);
  proto_string = remove_spaces(proto_string);
  
  cbox_add_select(cbox, proto_string);
  gtk_list_store_set (ep.gs, &it, 2, proto_string, -1);

  g_free (proto_string);
  gtk_widget_hide (glade_xml_get_widget (appdata.xml, "protocol_edit_dialog"));

  colors_changed = TRUE;
  color_list_to_pref ();
}				/* on_protocol_edit_ok_clicked */
Beispiel #12
0
/**
 * seahorse_util_string_up_first:
 * @orig: The utf8 string to work with
 *
 * Upper case the first char in the UTF8 string
 *
 * Returns: a new string, with the first char upper cased. The returned string
 * should be freed with #g_free when no longer needed.
 */
gchar*
seahorse_util_string_up_first (const gchar *orig)
{
    gchar *t, *t2, *ret;
    
    if (g_utf8_validate (orig, -1, NULL)) {
        
        t = g_utf8_find_next_char (orig, NULL); 
        if (t != NULL) {
            t2 = g_utf8_strup (orig, t - orig);
            ret = g_strdup_printf ("%s%s", t2, t);
            g_free (t2);
            
        /* Can't find first UTF8 char */
        } else {
            ret = g_strdup (orig);
        }
    
    /* Just use ASCII functions when not UTF8 */        
    } else {
        ret = g_strdup (orig);
        ret[0] = g_ascii_toupper (ret[0]);
    }
    
    return ret;
}
Beispiel #13
0
void
search_foreach(playlist_t * pl, GPatternSpec * pattern, GtkTreeIter * list_iter, int album_node) {

    char text[MAXLEN];
    char * tmp = NULL;
    playlist_data_t * pldata;

    gtk_tree_model_get(GTK_TREE_MODEL(pl->store), list_iter, PL_COL_DATA, &pldata, -1);
    if (album_node) {
        snprintf(text, MAXLEN-1, "%s: %s", pldata->artist, pldata->album);
    } else {
        playlist_data_get_display_name(text, pldata);
    }

    if (casesens) {
        tmp = strdup(text);
    } else {
        tmp = g_utf8_strup(text, -1);
    }

    if (g_pattern_match_string(pattern, tmp)) {

        GtkTreeIter iter;
        GtkTreePath * path;

        path = gtk_tree_model_get_path(GTK_TREE_MODEL(pl->store), list_iter);
        gtk_list_store_append(search_store, &iter);
        gtk_list_store_set(search_store, &iter, 0, text,
                           1, (gpointer)path, 2, pl->name, 3, (gpointer)pl, -1);
    }

    g_free(tmp);
}
Beispiel #14
0
/* Implementations of locale-specific operations; these are used
 * in the implementation of String.localeCompare(), Date.toLocaleDateString(),
 * and so forth. We take the straight-forward approach of converting
 * to UTF-8, using the appropriate GLib functions, and converting
 * back if necessary.
 */
static JSBool
gjs_locale_to_upper_case (JSContext *context,
                          JSString  *src,
                          jsval     *retval)
{
    JSBool success = JS_FALSE;
    char *utf8 = NULL;
    char *upper_case_utf8 = NULL;

    if (!gjs_string_to_utf8(context, STRING_TO_JSVAL(src), &utf8))
        goto out;

    upper_case_utf8 = g_utf8_strup (utf8, -1);

    if (!gjs_string_from_utf8(context, upper_case_utf8, -1, retval))
        goto out;

    success = JS_TRUE;

out:
    g_free(utf8);
    g_free(upper_case_utf8);

    return success;
}
Beispiel #15
0
static void
contact_draw (EContact *contact,
              EContactPrintContext *ctxt)
{
	GtkPageSetup *setup;
	gdouble page_height;
	gchar *file_as;
	gboolean new_section = FALSE;

	setup = gtk_print_context_get_page_setup (ctxt->context);
	page_height = gtk_page_setup_get_page_height (setup, GTK_UNIT_POINTS);

	file_as = e_contact_get (contact, E_CONTACT_FILE_AS);

	if (file_as != NULL) {
		gchar *section;
		gsize width;

		width = g_utf8_next_char (file_as) - file_as;
		section = g_utf8_strup (file_as, width);

		new_section = (ctxt->section == NULL ||
			g_utf8_collate (ctxt->section, section) != 0);

		if (new_section) {
			g_free (ctxt->section);
			ctxt->section = section;
		} else
			g_free (section);
	}

	if (new_section) {
		if (!ctxt->first_contact) {
			if (ctxt->style->sections_start_new_page)
				e_contact_start_new_page (ctxt);
			else if ((ctxt->y + e_contact_get_contact_height (
					contact, ctxt)) > page_height)
				e_contact_start_new_column (ctxt);
		}
		if (ctxt->style->letter_headings)
			e_contact_print_letter_heading (ctxt, ctxt->section);
		ctxt->first_section = FALSE;
	}

	else if (!ctxt->first_contact && ((ctxt->y +
		e_contact_get_contact_height (contact, ctxt)) > page_height)) {
		e_contact_start_new_column (ctxt);
		if (ctxt->style->letter_headings)
			e_contact_print_letter_heading (ctxt, ctxt->section);
	}

	e_contact_print_contact (contact, ctxt);

	ctxt->first_contact = FALSE;
}
Beispiel #16
0
void on_toggle_case1_activate(GtkMenuItem *menuitem, gpointer user_data)
{
	GeanyDocument *doc = document_get_current();
	ScintillaObject *sci;
	gchar *text;
	gboolean keep_sel = TRUE;

	g_return_if_fail(doc != NULL);

	sci = doc->editor->sci;
	if (! sci_has_selection(sci))
	{
		keybindings_send_command(GEANY_KEY_GROUP_SELECT, GEANY_KEYS_SELECT_WORD);
		keep_sel = FALSE;
	}

	/* either we already had a selection or we created one for current word */
	if (sci_has_selection(sci))
	{
		gchar *result = NULL;
		gint cmd = SCI_LOWERCASE;
		gboolean rectsel = (gboolean) scintilla_send_message(sci, SCI_SELECTIONISRECTANGLE, 0, 0);

		text = sci_get_selection_contents(sci);

		if (utils_str_has_upper(text))
		{
			if (rectsel)
				cmd = SCI_LOWERCASE;
			else
				result = g_utf8_strdown(text, -1);
		}
		else
		{
			if (rectsel)
				cmd = SCI_UPPERCASE;
			else
				result = g_utf8_strup(text, -1);
		}

		if (result != NULL)
		{
			sci_replace_sel(sci, result);
			g_free(result);
			if (keep_sel)
				sci_set_selection_start(sci, sci_get_current_position(sci) - strlen(text));
		}
		else
			sci_send_command(sci, cmd);

		g_free(text);

	}
}
Beispiel #17
0
gchar *
mousepad_util_utf8_strcapital (const gchar *str)
{
  gunichar     c;
  const gchar *p;
  gchar       *buf;
  GString     *result;
  gboolean     upper = TRUE;

  g_return_val_if_fail (g_utf8_validate (str, -1, NULL), NULL);

  /* create a new string */
  result = g_string_sized_new (strlen (str));

  /* walk though the string */
  for (p = str; *p != '\0'; p = g_utf8_next_char (p))
    {
      /* get the unicode char */
      c = g_utf8_get_char (p);

      /* only change the case of alpha chars */
      if (g_unichar_isalpha (c))
        {
          /* check case */
          if (upper ? g_unichar_isupper (c) : g_unichar_islower (c))
            {
              /* currect case is already correct */
              g_string_append_unichar (result, c);
            }
          else
            {
              /* convert the case of the char and append it */
              buf = upper ? g_utf8_strup (p, 1) : g_utf8_strdown (p, 1);
              g_string_append (result, buf);
              g_free (buf);
            }

          /* next char must be lowercase */
          upper = FALSE;
        }
      else
        {
          /* append the char */
          g_string_append_unichar (result, c);

          /* next alpha char uppercase after a space */
          upper = g_unichar_isspace (c);
        }
    }

  /* return the result */
  return g_string_free (result, FALSE);
}
Beispiel #18
0
/*
 *  call-seq:
 *    utf8_upcase(string)
 *
 *  Returns the string in capitals if they are are available for the supplied characters.
 *
 *    Glib.utf8_upcase('Sluß') #=> SLUSS
 */
static VALUE utf8_upcase(VALUE self, VALUE string)
{
  VALUE result;
  gchar *temp;

  Check_Type(string, T_STRING);
  temp = g_utf8_strup(StringValuePtr(string), RSTRING_LEN(string));
  result = rb_str_new2(temp);
  free(temp);

  return result;
}
static void
filter_changed (GtkBuilder *builder)
{
  GtkTreeModelFilter *filtered_model;
  GtkTreeView *tree_view;
  GtkTreeSelection *selection;
  GtkTreeIter selected_iter;
  GtkWidget *filter_entry;
  const gchar *pattern;
  gchar *upattern;

  filter_entry = WID ("input_source_filter");
  pattern = gtk_entry_get_text (GTK_ENTRY (filter_entry));
  upattern = g_utf8_strup (pattern, -1);
  if (!g_strcmp0 (pattern, ""))
    g_object_set (G_OBJECT (filter_entry),
                  "secondary-icon-name", "edit-find-symbolic",
                  "secondary-icon-activatable", FALSE,
                  "secondary-icon-sensitive", FALSE,
                  NULL);
  else
    g_object_set (G_OBJECT (filter_entry),
                  "secondary-icon-name", "edit-clear-symbolic",
                  "secondary-icon-activatable", TRUE,
                  "secondary-icon-sensitive", TRUE,
                  NULL);

  if (search_pattern_list != NULL)
    g_strfreev (search_pattern_list);

  search_pattern_list = g_strsplit (upattern, " ", -1);
  g_free (upattern);

  filtered_model = GTK_TREE_MODEL_FILTER (gtk_builder_get_object (builder, "filtered_input_source_model"));
  gtk_tree_model_filter_refilter (filtered_model);

  tree_view = GTK_TREE_VIEW (WID ("filtered_input_source_list"));
  selection = gtk_tree_view_get_selection (tree_view);
  if (gtk_tree_selection_get_selected (selection, NULL, &selected_iter))
    {
      GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (filtered_model),
                                                   &selected_iter);
      gtk_tree_view_scroll_to_cell (tree_view, path, NULL, TRUE, 0.5, 0.5);
      gtk_tree_path_free (path);
    }
  else
    {
      GtkTreeIter iter;
      if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (filtered_model), &iter))
        gtk_tree_selection_select_iter (selection, &iter);
    }
}
Beispiel #20
0
fs_value fn_ucase(fs_query *q, fs_value v)
{
    if (!fs_is_plain_or_string(v)) {
        return fs_value_error(FS_ERROR_INVALID_TYPE, NULL);
    }
    v = fs_value_fill_lexical(q, v);
    char *lex = g_utf8_strup(v.lex, -1);
    fs_query_add_freeable(q, lex);
    fs_value ret = fs_value_plain(lex);
    ret.attr = v.attr;

    return ret;
}
Beispiel #21
0
RESULT
test_utf8_strcase_each (const gchar *src, const gchar *expected, gboolean strup)
{
	gchar *tmp;
	glong len, len2;
	RESULT r;

	len = utf8_byteslen (src);
	tmp = strup ? g_utf8_strup (src, len) : g_utf8_strdown (src, len);
	len2 = utf8_byteslen (tmp);
	r = compare_strings_utf8_RESULT (expected, tmp, len < len2 ? len2 : len);
	g_free (tmp);
	return r;
}
Beispiel #22
0
static char *
get_type_name (char *filename)
{
	char *ext;

	ext = strrchr (filename, '.');
	if (!ext)
		return g_strdup (_("Unknown"));
	ext = g_utf8_strup (ext + 1, -1);

	if (strcmp (ext, "BMP") == 0) {
		g_free (ext);
		return g_strdup (_("Bitmap Image"));

	} else if (strcmp (ext, "JPG") == 0) {
		g_free (ext);
		return g_strdup (_("JPEG Image"));

	} else if (strcmp (ext, "GIF") == 0) {
		g_free (ext);
		return g_strdup (_("GIF Image"));

	} else if (strcmp (ext, "PNG") == 0) {
		g_free (ext);
		return g_strdup (_("PNG Image"));

	} else if (strcmp (ext, "TXT") == 0) {
		g_free (ext);
		return g_strdup (_("Text File"));

	} else if (strcmp (ext, "WAV") == 0) {
		g_free (ext);
		return g_strdup (_("Wave Sound"));

	} else if (strcmp (ext, "MP3") == 0) {
		g_free (ext);
		return g_strdup (_("MP3 Music"));

	} else if (strcmp (ext, "SPR") == 0) {
		g_free (ext);
		return g_strdup (_("Sprite Data"));

	} else if (strcmp (ext, "XML") == 0) {
		g_free (ext);
		return g_strdup (_("XML Document"));

	} else
		return ext;
}
static void
xsltp_extension_string_uc(xmlXPathParserContextPtr ctxt, int nargs) {
    xmlChar *str;

    if (nargs != 1) {
        xmlXPathSetArityError(ctxt);
        return;
    }

    str = xmlXPathPopString(ctxt);

    xmlXPathReturnString(ctxt, (xmlChar *) g_utf8_strup((const gchar *) str, -1));

    xmlFree(str);
}
Beispiel #24
0
static gboolean is_date_column(sqlite3_stmt* query, int i)
{
	gboolean res;
	const char* column_type		= sqlite3_column_decltype(query, i);
	char* column_type_up		= (column_type == NULL)? NULL: g_utf8_strup(column_type, -1);

	if((column_type_up != NULL) && (strcmp(column_type_up, "DATE") == 0))
		res = TRUE;
	else
		res = FALSE;

	g_free(column_type_up);

	return res;
}
static gboolean
xkb_filter_layouts (GtkTreeModel * model,
		    GtkTreeIter * iter, gpointer data)
{
	gchar *desc = NULL, *country_desc = NULL, *language_desc =
	    NULL, **pattern;
	gboolean rv = TRUE;

	if (search_pattern_list == NULL || search_pattern_list[0] == NULL)
		return TRUE;

	gtk_tree_model_get (model, iter,
			    COMBO_BOX_MODEL_COL_SORT, &desc,
			    COMBO_BOX_MODEL_COL_COUNTRY_DESC,
			    &country_desc,
			    COMBO_BOX_MODEL_COL_LANGUAGE_DESC,
			    &language_desc, -1);

	pattern = search_pattern_list;
	do {
		gboolean is_pattern_found = FALSE;
		gchar *udesc = g_utf8_strup (desc, -1);
		if (udesc != NULL && g_strstr_len (udesc, -1, *pattern)) {
			is_pattern_found = TRUE;
		} else if (country_desc != NULL
			   && g_strstr_len (country_desc, -1, *pattern)) {
			is_pattern_found = TRUE;
		} else if (language_desc != NULL
			   && g_strstr_len (language_desc, -1, *pattern)) {
			is_pattern_found = TRUE;
		}
		g_free (udesc);

		if (!is_pattern_found) {
			rv = FALSE;
			break;
		}

	} while (*++pattern != NULL);

	g_free (desc);
	g_free (country_desc);
	g_free (language_desc);
	return rv;
}
Beispiel #26
0
SWORD_NAMESPACE_START

char *GS_StringMgr::upperUTF8(char *text, unsigned int maxlen) const
{
	if ((text == NULL) || (*text == '\0')) {
		return g_strdup("");
	}
	if (maxlen == 0)
		maxlen = strlen(text);
	char *upper_str = g_utf8_strup(text, -1);
	unsigned int newlen = strlen(upper_str);
	if (newlen >= maxlen)
		newlen = maxlen;
	memcpy(text, upper_str, newlen);
	//text[newlen] = 0;	// be sure we're null terminated.
	g_free(upper_str);
	return text;
}
int main()
{
    static char buffer[1048576];
    size_t read_bytes = fread(buffer, 1, sizeof(buffer) - 1, stdin);
    printf("%zu\n", read_bytes);
    if (read_bytes < 1) {
        return EXIT_FAILURE;
    }
    size_t data_bytes = read_bytes;
    char* buffer_pointer = buffer;

    g_free(g_utf8_strup(buffer_pointer, data_bytes));
    g_free(g_utf8_strdown(buffer_pointer, data_bytes));
    g_free(g_utf8_normalize(buffer_pointer, data_bytes, G_NORMALIZE_DEFAULT));
    g_free(g_utf8_collate_key(buffer_pointer, data_bytes));
    g_free(g_utf8_collate_key_for_filename(buffer_pointer, data_bytes));
    return EXIT_SUCCESS;
}
Beispiel #28
0
static EnchantTrie* enchant_trie_get_subtrie(EnchantTrie* trie, 
											 EnchantTrieMatcher* matcher,
											 char** nxtChS)
{
	EnchantTrie* subtrie;

	if(trie->subtries == NULL || *nxtChS == NULL)
		return NULL;

	subtrie = g_hash_table_lookup(trie->subtries,*nxtChS);
	if(subtrie == NULL && matcher->mode == case_insensitive) {
		char* nxtChSUp = g_utf8_strup(*nxtChS, -1); /* we ignore the title case scenario since that will give us an edit_distance of one which is acceptable since this mode is used for suggestions*/
		g_free(*nxtChS);
		*nxtChS = nxtChSUp;
		subtrie = g_hash_table_lookup(trie->subtries,nxtChSUp);
	}
	return subtrie;
}
Beispiel #29
0
gchar *
mousepad_util_utf8_stropposite (const gchar *str)
{
  gunichar     c;
  const gchar *p;
  gchar       *buf;
  GString     *result;

  g_return_val_if_fail (g_utf8_validate (str, -1, NULL), NULL);

  /* create a new string */
  result = g_string_sized_new (strlen (str));

  /* walk though the string */
  for (p = str; *p != '\0'; p = g_utf8_next_char (p))
    {
      /* get the unicode char */
      c = g_utf8_get_char (p);

      /* only change the case of alpha chars */
      if (g_unichar_isalpha (c))
        {
          /* get the opposite case of the char */
          if (g_unichar_isupper (c))
            buf = g_utf8_strdown (p, 1);
          else
            buf = g_utf8_strup (p, 1);

          /* append to the buffer */
          g_string_append (result, buf);
          g_free (buf);
        }
      else
        {
          /* append the char */
          g_string_append_unichar (result, c);
        }
    }

  /* return the result */
  return g_string_free (result, FALSE);
}
Beispiel #30
0
/* Class methods */
static LibBalsaABErr
libbalsa_address_book_rubrica_load(LibBalsaAddressBook * ab,
				   const gchar * filter,
				   LibBalsaAddressBookLoadFunc callback,
				   gpointer data)
{
    LibBalsaAddressBookRubrica *ab_rubrica =
	LIBBALSA_ADDRESS_BOOK_RUBRICA(ab);
    LibBalsaAddressBookText *ab_text = LIBBALSA_ADDRESS_BOOK_TEXT(ab);
    LibBalsaABErr load_res;
    gchar *filter_hi = NULL;
    GSList *list;

    g_return_val_if_fail(ab_text->path != NULL, LBABERR_CANNOT_READ);

    /* try to load the xml file if necessary */
    load_res = lbab_rubrica_load_xml(ab_rubrica, NULL);
    if (load_res != LBABERR_OK)
	return load_res;

    if (filter)
	filter_hi = g_utf8_strup(filter, -1);

    for (list = ab_text->item_list; list; list = list->next) {
	LibBalsaAddress *address = LIBBALSA_ADDRESS(list->data);

	if (!address)
	    continue;

	if (callback &&
	    (!filter_hi ||
	     lbab_rubrica_starts_from(address->last_name, filter_hi) ||
	     lbab_rubrica_starts_from(address->full_name, filter_hi)))
	    callback(ab, address, data);
    }
    if (callback)
	callback(ab, NULL, data);

    g_free(filter_hi);

    return LBABERR_OK;
}