Coding a PDF Text Parser in swift

414 Views Asked by At

I'm currently developing a pdf text parser completely in swift. I was looking trough the PDFKittens code and found this in the stringwithpdfstring method (In SimpleFont.m) taking a CGPDFStringRef as parameter.

  const unsigned char *bytes = CGPDFStringGetBytePtr(pdfString);
  NSUInteger length = CGPDFStringGetLength(pdfString);


    // Translate to Unicode
    for (int i = 0; i < length; i++)
    {
        unichar cid = bytes[i];
        unichar uni = [self.toUnicode unicodeCharacter:cid];
    }

From my understanding *bytes is a CChar, what is this method exactly iterating trough? When I translate this code to swift I receive the error that Type UnsafePointer? has no subscript members. What is the equivalent of that objective c code in swift...?

0

There are 0 best solutions below