• 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
Re: &xxx; thingies
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: &xxx; thingies


  • Subject: Re: &xxx; thingies
  • From: Jeff LaMarche <email@hidden>
  • Date: Sat, 17 Nov 2001 22:16:15 -0500

Here's how I did it - it doesn't require a lookup table, as long as you know that the URL you'll be encoding only has ASCII-8 characters. I think this will work with some extended characters, but not with the full range of characters available in Unicode...


-(NSString *)encodeChar:(char)inChar
{
char *lookup = "0123456789ABCDEF";
return [NSString stringWithFormat:@"%%%c%c", lookup[(int)inChar / 16], lookup[(int)inChar % 16]];
}


Jeff
On Saturday, November 17, 2001, at 06:40 AM, Scott Anguish wrote:

Total lazy man hack here.. (there are better ways to do this.. but they'd require a big table of the values to map to)

load the NSString into an NSText instance as HTML, and then grab the string from the text.

Like I said.. TOTAL hack.. (not sure, but it might ruin any whitespace/returns)

I'd love to see an NSEncoding mode that handled HTML so you could move between the escaped and unescaped stuff easily...

On Saturday, November 17, 2001, at 01:50 AM, Angela Brett wrote:

Hi,

I know I could do this myself but I'm sure it's already been done. What should I use to go through an NSString and turn the &amp; etc used in HTML into the characters they represent? It looks as if the Omniweb framework can do it, but I haven't figured out how yet. I don't really want to add all the Omni frameworks to my project just for that, so if someone could tell me about a simple way of doing it I'd be most grateful.
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev


  • Follow-Ups:
    • Re: &xxx; thingies
      • From: Scott Anguish <email@hidden>
References: 
 >Re: &xxx; thingies (From: Scott Anguish <email@hidden>)

  • Prev by Date: Re: Standard OS X Compression format
  • Next by Date: NSJPEGFileType / JPEG writer
  • Previous by thread: Re: &xxx; thingies
  • Next by thread: Re: &xxx; thingies
  • Index(es):
    • Date
    • Thread