Latest 1.1.1
Homepage https://github.com/dbgrandi/DBGHTMLEntities
License MIT
Platforms ios 6.0, osx 10.8, tvos 9.0, watchos 2.0, requires ARC
Authors

Build Status
Version
Platform

Usage

To run the example project; clone the repo, and run pod install from the Example directory first.

Or, for the easiest, run pod try DBGHTMLEntities

To do a simple string decode:

NSString *encodedString = @"Texas A&M needs decoding.";
DBGHTMLEntityDecoder *decoder = [[DBGHTMLEntityDecoder alloc] init];
NSString *decodedString = [decoder decodeString:encodedString];

If you have an NSMutableString you can decode in place using:

NSMutableString *encodedString = @"OH: "Parse all the strings!"";
DBGHTMLEntityDecoder *decoder = [[DBGHTMLEntityDecoder alloc] init];
[decoder decodeStringInPlace:encodedString];

The second method, decodeStringInPlace: was created explicitly for an issue I had while manipulating NSAttributedStrings to show Tweets with highlighted hashtags, user mentions, and proper URLs based on the Tweet entities. I ended up setting up highlighting attributes on parts of an NSMutableAttributedString and then calling decodeStringInPlace:

NSMutableAttributedString *tweetString = ...

// highlight user_mentions
// highlight hashtags
// replace urls

DBGHTMLEntityDecoder *decoder = [[DBGHTMLEntityDecoder alloc] init];
[decoder decodeStringInPlace:tweetString.mutableString];

tweetLabel.attributedText = tweetString;

Installation

DBGHTMLEntities is available through CocoaPods, to install
it simply add the following line to your Podfile:

pod "DBGHTMLEntities"

Author

David Grandinetti, [email protected]

Inspiration

This was essentially a lazy port from the htmlentities RubyGem by Paul Battley. Paul did a better job of providing more granular options. I really just needed
the decoder options, so the encoder is not as configurable as his, yet.

License

DBGHTMLEntities is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "DBGHTMLEntities",
    "version": "1.1.1",
    "summary": "Easily Decode/Encode HTML entity strings (e.g. &)",
    "description": "Easily Decode/Encode HTML entity strings (e.g. &). Tested, and with a sexy LICENSE.",
    "homepage": "https://github.com/dbgrandi/DBGHTMLEntities",
    "screenshots": "http://i.imgur.com/3qAOJig.gif",
    "license": "MIT",
    "authors": {
        "David Grandinetti": "[email protected]"
    },
    "source": {
        "git": "https://github.com/dbgrandi/DBGHTMLEntities.git",
        "tag": "1.1.1"
    },
    "social_media_url": "https://twitter.com/dbgrandi",
    "platforms": {
        "ios": "6.0",
        "osx": "10.8",
        "tvos": "9.0",
        "watchos": "2.0"
    },
    "requires_arc": true,
    "source_files": "Classes",
    "private_header_files": "Classes/**/*+Private.h",
    "public_header_files": "Classes/**/*.h"
}

Pin It on Pinterest

Share This