Re: Converting an HTML source string to a readable string
Re: Converting an HTML source string to a readable string
- Subject: Re: Converting an HTML source string to a readable string
- From: Eric Morand <email@hidden>
- Date: Fri, 12 May 2006 11:26:16 +0200
Thanks Conor !!! It works perfectly !
I have not read what your method does yet (I just added it to my
class) but the result is perfect ! :o)
Again, thanks, you made my day !
Eric.
Le 12 mai 06 à 11:09, Conor Dearden a écrit :
[self convertHTMLEncoding:MyString];
Add this function to your class:
- (NSString *)convertHTMLEncoding:(NSString *)aString {
NSMutableString *tempMutableString = [NSMutableString
stringWithCapacity:150];
[tempMutableString setString:aString];
while (YES) {
int tempInt = 0;
NSScanner *searchScanner = [NSScanner
scannerWithString:tempMutableString];
[searchScanner scanUpToString:@"&#" intoString:nil];
if ([searchScanner isAtEnd])
break;
[searchScanner setScanLocation:[searchScanner scanLocation]
+2];
[searchScanner scanInt:&tempInt];
if (tempInt) {
if ([tempMutableString replaceOccurrencesOfString:
[NSString
stringWithFormat:@"&#%d;", tempInt] withString:[NSString
stringWithFormat:@"%C", tempInt] options:NSLiteralSearch
range:NSMakeRange(0, [tempMutableString length])] == 0)
[tempMutableString
deleteCharactersInRange:NSMakeRange([searchScanner scanLocation]
-2 ,2)];
}
else
[tempMutableString
deleteCharactersInRange:NSMakeRange([searchScanner scanLocation]
-2 ,2)];
}
return tempMutableString;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden