public static int strlen(this IntPtr nativeUtf8) { int len = 0; if (nativeUtf8 != IntPtr.Zero) { while (Marshal.ReadByte(nativeUtf8, len) != 0) ++len; } return len; }