CFStringRefãSVã«å¤æ
追è¨: id:tokuhiromå çã«æ·»åãã¦ããã£ãã
- malloc使ãã¹ããã -> NewXX()ç³»ã§ã¢ãã±ã¼ããSafeFree()ã§è§£æ¾ãã¹ã(ããããã°id:hirose31ãããè¨ã£ã¦ã)
- newSVpvã®ç¬¬äºå¼æ°(STRLEN)ã¯æ示çã«æå®ãã¹ã -> 0ã§èªåè¨ç®ã¯\0 çµç«¯åæ
SV * getString(CFStringRef var) { char *buf; SV *sv; CFIndex len = CFStringGetLength(val); CFIndex max = CFStringGetMaximumSizeForEncoding(len, kCFStringEncodingUTF8); buf = Newxz(max + 1); CFStringGetCString(val, buf, max + 1, kCFStringEncodingUTF8); CFRelease(val); sv = newSVpv(buf, max); SafeFree(buf); return sv; }