Skip to content

Instantly share code, notes, and snippets.

@hidek
Created July 23, 2009 07:40
Show Gist options
  • Select an option

  • Save hidek/152506 to your computer and use it in GitHub Desktop.

Select an option

Save hidek/152506 to your computer and use it in GitHub Desktop.
SV * getString(CFStringRef var) {
char *buf;
SV *sv;
CFIndex len = CFStringGetLength(val);
CFIndex max = CFStringGetMaximumSizeForEncoding(len, kCFStringEncodingUTF8) + 1;
Newxz(buf, max, char);
CFStringGetCString(val, buf, max, kCFStringEncodingUTF8);
CFRelease(val);
sv = newSVpv(buf, max);
Safefree(buf);
return sv;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment