Ask a Question related to Mac Programming, Design and Development.
-
Simon Slavin #1
Cocoa: simple HTML text to Unicode
I have an NSString. 99% of the time it contains just text.
Sometimes one or more characters of the string will be encoded
in HTML, like the following:
Time for Questions & Answers.
What's the simplest method I can use to turn this into normal
text (I assume Unicode) ? There will never be any image or
link information in the string, just encoded text.
Simon Slavin Guest
-
Cannot read Unicode from html blog
With Acrobat 7.0.8 I tried to create a PDF from <http://ardentagnostic.blogspot.com/2006/09/bad-guys-are-also-good-guys-but.html> Problem 1: The... -
Importing greek unicode characters from html page
When importing greek unicode characters from a html file, Adobe does not map these characters to unicode but to a greek font that does not inlude... -
increase the text box size-simple html help!
This isn't an ASP question. Size should increase the size, unless it is limited by other factors, e.g. a width parameter in a style sheet for... -
Converting simple text to HTML
Is there a way to convert ASCII text entered into a textbox, for example, into HTML so that newlines will be turned into <BR> tags or similar among... -
[cocoa richt text] named styles
Hi, the RTF does support named styles for paragraphs and characters. I did not find any reference to that in the Cocoa documentation. How can I... -
Tom Harrington #2
Re: Cocoa: simple HTML text to Unicode
In article <BB8179049668744EF6@10.0.1.2>,
[email]slavins@hearsay.demon.co.uk[/email]@localhost (Simon Slavin) wrote:
One likely approach is as follows, though I have not tried it:> I have an NSString. 99% of the time it contains just text.
> Sometimes one or more characters of the string will be encoded
> in HTML, like the following:
>
> Time for Questions & Answers.
>
> What's the simplest method I can use to turn this into normal
> text (I assume Unicode) ? There will never be any image or
> link information in the string, just encoded text.
1. Load the NSString into an NSAttributedString, using
NSAttributedString's -initWithHTML:documentAttributes initializer.
2. Follow that by converting the attributed string back to an
un-attributed one.
--
Tom "Tom" Harrington
Macaroni, Automated System Maintenance for Mac OS X.
Version 1.4: Best cleanup yet, gets files other tools miss.
See [url]http://www.atomicbird.com/[/url]
Tom Harrington Guest
-
Paul Mitchum #3
Re: Cocoa: simple HTML text to Unicode
<slavins@hearsay.demon.co.uk> wrote:
Search the string for HTML-encoded character entities and then convert> I have an NSString. 99% of the time it contains just text. Sometimes one
> or more characters of the string will be encoded in HTML, like the
> following:
>
> Time for Questions & Answers.
>
> What's the simplest method I can use to turn this into normal text (I
> assume Unicode) ? There will never be any image or link information in
> the string, just encoded text.
them. :-) Numeric entities are assumed to be Unicode. Details:
<http://makeashorterlink.com/?M10E233D5>
Look at NSScanner, for some clues about how you might accomplish this.
Paul Mitchum Guest
-
Doc O'Leary #4
Re: Cocoa: simple HTML text to Unicode
In article <BB8179049668744EF6@10.0.1.2>,
[email]slavins@hearsay.demon.co.uk[/email]@localhost (Simon Slavin) wrote:
My dirty little trick for this (used in STXML) was to note that Apple> What's the simplest method I can use to turn this into normal
> text (I assume Unicode) ? There will never be any image or
> link information in the string, just encoded text.
provides a perfectly fine entity decoder for XML to handle property
lists, although they don't provide a detached interface to it. So I do
something like:
decodedString = [[NSString stringWithFormat: @"<string>%@</string>",
encodedString] propertyList];
Doc O'Leary Guest



Reply With Quote

