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
3 changed files with 18 additions and 3 deletions
|
@ -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>
|
||||
|
||||
* gtk/Style.custom : add bg_pixmap accessors. remove IntPtr[] vars
|
||||
|
|
|
@ -37,15 +37,15 @@ namespace GLib {
|
|||
g_free (ptr);
|
||||
}
|
||||
|
||||
[DllImport("libglib-2.0-0.dll")]
|
||||
static extern IntPtr g_utf8_strlen (IntPtr mem, int size);
|
||||
[DllImport("glibsharpglue-2")]
|
||||
static extern UIntPtr glibsharp_strlen (IntPtr mem);
|
||||
|
||||
public static string Utf8PtrToString (IntPtr ptr)
|
||||
{
|
||||
if (ptr == IntPtr.Zero)
|
||||
return null;
|
||||
|
||||
int len = (int) g_utf8_strlen (ptr, -1);
|
||||
int len = (int) (uint)glibsharp_strlen (ptr);
|
||||
byte[] bytes = new byte [len];
|
||||
Marshal.Copy (ptr, bytes, 0, len);
|
||||
return System.Text.Encoding.UTF8.GetString (bytes);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
/* Forward declarations */
|
||||
gchar *gtksharp_unichar_to_utf8_string (gunichar chr);
|
||||
gunichar glibsharp_utf16_to_unichar (guint16 chr);
|
||||
gssize glibsharp_strlen (gchar *s);
|
||||
/* */
|
||||
|
||||
gchar *
|
||||
|
@ -48,3 +49,11 @@ glibsharp_utf16_to_unichar (guint16 chr)
|
|||
return result;
|
||||
}
|
||||
|
||||
gssize
|
||||
glibsharp_strlen (gchar *s)
|
||||
{
|
||||
gssize cnt = 0;
|
||||
for (cnt = 0; *s; s++, cnt++);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue