After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 469053 - g_unichar_to/from_string()
g_unichar_to/from_string()
Status: RESOLVED WONTFIX
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2007-08-21 23:57 UTC by Behdad Esfahbod
Modified: 2009-04-08 20:57 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Behdad Esfahbod 2007-08-21 23:57:28 UTC
Not sure how feasible these mostly trivial functions are, but can be useful for debugging, etc, (and in my case, for storing gunichar in gconf in a readable way).

Essentially equivalent to:

char     *g_unichar_to_string   (gunichar ch) G_GNUC_MALLOC;
gunichar  g_unichar_from_string (const char *s);

char *
g_unichar_to_string (gunichar ch)
{
  char s[32];
  g_snprintf (s, sizeof (s), "U+%04X", ch);
  s[sizeof (s) - 1] = '\0';
  return strdup (s);
}

gunichar
g_unichar_from_string (const char *s)
{
  gunichar c = (gunichar) -1;
  sscanf (s, "[Uu]+%X", &c);
  return c;
}

Not sure from_string() should parse other formats like Ӓ and ካ too or not.
Comment 1 Behdad Esfahbod 2009-04-08 20:57:07 UTC
I documented how to read/write gunichars as part of bug 563156.  Lets say this is not needed anymore.