mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-16 11:34:47 +02:00
2005-03-10 Mike Kestner <mkestner@novell.com>
* glib/Marshaller.cs : don't use g_utf8_strlen to determine the byte count to be copied, it returns chars, not bytes. * glib/glue/unichar.c : implement a quick and dirty strlen glue func. svn path=/trunk/gtk-sharp/; revision=41661
This commit is contained in:
parent
b394413480
commit
ac91f1c8b1
@ -1,3 +1,9 @@
|
|||||||
|
2005-03-10 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
|
* glib/Marshaller.cs : don't use g_utf8_strlen to determine the byte
|
||||||
|
count to be copied, it returns chars, not bytes.
|
||||||
|
* glib/glue/unichar.c : implement a quick and dirty strlen glue func.
|
||||||
|
|
||||||
2005-03-10 Mike Kestner <mkestner@novell.com>
|
2005-03-10 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* gtk/Style.custom : add bg_pixmap accessors. remove IntPtr[] vars
|
* gtk/Style.custom : add bg_pixmap accessors. remove IntPtr[] vars
|
||||||
|
@ -37,15 +37,15 @@ namespace GLib {
|
|||||||
g_free (ptr);
|
g_free (ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("libglib-2.0-0.dll")]
|
[DllImport("glibsharpglue-2")]
|
||||||
static extern IntPtr g_utf8_strlen (IntPtr mem, int size);
|
static extern UIntPtr glibsharp_strlen (IntPtr mem);
|
||||||
|
|
||||||
public static string Utf8PtrToString (IntPtr ptr)
|
public static string Utf8PtrToString (IntPtr ptr)
|
||||||
{
|
{
|
||||||
if (ptr == IntPtr.Zero)
|
if (ptr == IntPtr.Zero)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
int len = (int) g_utf8_strlen (ptr, -1);
|
int len = (int) (uint)glibsharp_strlen (ptr);
|
||||||
byte[] bytes = new byte [len];
|
byte[] bytes = new byte [len];
|
||||||
Marshal.Copy (ptr, bytes, 0, len);
|
Marshal.Copy (ptr, bytes, 0, len);
|
||||||
return System.Text.Encoding.UTF8.GetString (bytes);
|
return System.Text.Encoding.UTF8.GetString (bytes);
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
/* Forward declarations */
|
/* Forward declarations */
|
||||||
gchar *gtksharp_unichar_to_utf8_string (gunichar chr);
|
gchar *gtksharp_unichar_to_utf8_string (gunichar chr);
|
||||||
gunichar glibsharp_utf16_to_unichar (guint16 chr);
|
gunichar glibsharp_utf16_to_unichar (guint16 chr);
|
||||||
|
gssize glibsharp_strlen (gchar *s);
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
@ -48,3 +49,11 @@ glibsharp_utf16_to_unichar (guint16 chr)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gssize
|
||||||
|
glibsharp_strlen (gchar *s)
|
||||||
|
{
|
||||||
|
gssize cnt = 0;
|
||||||
|
for (cnt = 0; *s; s++, cnt++);
|
||||||
|
return cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user