Search code examples
iphoneobjective-cpdfunicodeunichar

Convert or Print CGPDFStringRef string


How to convert a CGPDFStringRef to unicode char? I have used CGPDFStringCopyTextString to get the string and then [string characterAtIndex:i] to cast to unichar, is this the right way? or is there any way to get the bytes of the string and convert to unicode directly? Need some guidance here.


Solution

  • NSString is capable of handling of unicode characters itself, you just need to convert the CGPDFString to NSString and further you can use it as follows:

    NSString *tempStr = (NSString *)CGPDFStringCopyTextString(objectString);