• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
stringWithQuotedPrintableString almost perfect
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

stringWithQuotedPrintableString almost perfect


  • Subject: stringWithQuotedPrintableString almost perfect
  • From: Brad Stone <email@hidden>
  • Date: Thu, 19 Aug 2010 22:27:32 -0400

Can someone help me figure out why (brackets not included)  [•	m]  (which is, on the Mac, an option-8 character, a tab character and a lowercase m) converts to (brackets not included [‚Ä¢ m] ?

The source text  is quoted-printable UTF-8 text I created and saved in an XML file in a different application.  All the other characters and line returns translate perfectly but this option-8 tab combination does not.

Here is my source code.

Thanks

- (NSString *)stringWithQuotedPrintableString:(const char *)qpString {

    const char *p = qpString;
    char *ep, *utf8_string = malloc(strlen(qpString) * sizeof(char));
    NSParameterAssert( utf8_string );
    ep = utf8_string;



    while( *p ) {

        switch( *p ) {
			case '=':

				NSAssert1( *(p + 1) != 0 && *(p + 2) != 0, @"Malformed QP String: %s", qpString);
				if( *(p + 1) != '\r' ) {
					int i, byte[2];
					for( i = 0; i < 2; i++ ) {
						byte[i] = *(p + i + 1);
						if( isdigit(byte[i]) )
							byte[i] -= 0x30;
						else
							byte[i] -= 0x37;

						if (byte[i] >= 0 && byte[i] < 16) {
							continue;
						}

						NSAssert( byte[i] >= 0 && byte[i] < 16, @"bad encoded character");
					}
					*(ep++) = (char) (byte[0] << 4) | byte[1];
				}
				p += 3;
				continue;
			default:
				*(ep++) = *(p++);
				continue;
        }
    }
	return [[NSString alloc] initWithBytesNoCopy:utf8_string length:strlen(utf8_string) encoding:NSUTF8StringEncoding freeWhenDone:YES];
}





_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: stringWithQuotedPrintableString almost perfect
      • From: "Stephen J. Butler" <email@hidden>
    • Re: stringWithQuotedPrintableString almost perfect
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Set the Cursor Position
  • Next by Date: Re: Losing my memory - a caching problem?
  • Previous by thread: Re: Set the Cursor Position
  • Next by thread: Re: stringWithQuotedPrintableString almost perfect
  • Index(es):
    • Date
    • Thread