private string CFString() { if (typeRef == IntPtr.Zero) return null; string str; int length = CFLibrary.CFStringGetLength(typeRef); IntPtr u = CFLibrary.CFStringGetCharactersPtr(typeRef); IntPtr buffer = IntPtr.Zero; if (u == IntPtr.Zero) { CFRange range = new CFRange(0, length); buffer = Marshal.AllocCoTaskMem(length * 2); CFLibrary.CFStringGetCharacters(typeRef, range, buffer); u = buffer; } unsafe { str = new string((char*)u, 0, length); } if (buffer != IntPtr.Zero) Marshal.FreeCoTaskMem(buffer); return str; }
public static unsafe extern void CFDataGetBytes(IntPtr theData, CFRange range, IntPtr buffer);
internal static extern void CFArrayGetValues(IntPtr intptr, CFRange cfrange, IntPtr intptr_1);
public static unsafe extern IntPtr CFStringGetCharacters(IntPtr handle, CFRange range, IntPtr buffer);
public static extern int CFStringGetBytes(IntPtr theString, CFRange range, uint encoding, byte lossByte, byte isExternalRepresentation, byte[] buffer, int maxBufLen, ref int usedBufLen);
static extern internal bool /* Boolean */ CFStringTransform(/* CFMutableStringRef* */ IntPtr @string, /* CFRange* */ ref CFRange range, /* CFStringRef* */ IntPtr transform, [MarshalAs(UnmanagedType.I1)] /* Boolean */ bool reverse);
public bool Transform(ref CFRange range, NSString transform, bool reverse) { return(Transform(ref range, transform.GetHandle(), reverse)); }
public static extern void CFDataGetBytes(IntPtr theData, CFRange range, IntPtr buffer);
public static extern IntPtr CFStringGetCharacters(IntPtr handle, CFRange range, IntPtr buffer);
extern static unsafe IntPtr CFStringGetCharacters(IntPtr handle, CFRange range, char *buffer);
public bool Transform(ref CFRange range, CFStringTransform transform, bool reverse) { return(Transform(ref range, transform.GetConstant().GetHandle(), reverse)); }