PHPackages                             marc-mabe/entity-coder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. marc-mabe/entity-coder

AbandonedArchivedLibrary[Parsing &amp; Serialization](/categories/parsing)

marc-mabe/entity-coder
======================

Encode &amp; decode XML, HTML and own defined entities into different charsets

7182PHP

Since Feb 7Pushed 5y ago1 watchersCompare

[ Source](https://github.com/marc-mabe/entity-coder)[ Packagist](https://packagist.org/packages/marc-mabe/entity-coder)[ RSS](/packages/marc-mabe-entity-coder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

entity-coder
============

[](#entity-coder)

!!! ARCHIVED !!!
================

[](#-archived-)

THIS REPOSITORY HAS BEEN ARCHIVED WITHOUT ANY REPLACEMENT
=========================================================

[](#this-repository-has-been-archived-without-any-replacement)

Encode &amp; decode XML, HTML and own defined entities into different charsets.

FEATURES
--------

[](#features)

- decode and encode hex entities
- decode and encode decimal entities
- convert from one charset to another
- selectable if named entities will be used (on encode)
- selectable if hex or decimal entities will be used (on encode)
- selectable how to handle characters/entities which are not convertable to given output charset
- selectable how to handle invalid characters
- **ACTIONS:**
    - throw exception
    - call callback
    - ignore
    - substitute by a substitution character
    - use entity
    - translit by ASCII name

Usage
-----

[](#usage)

**Encode**

```
$entityCoder = new EntityCoder(array(
    // set named entity reference
    // -> 'special', 'xml', 'html' or an array of your own entities
    'entityReference' => 'special',

    // set your input charset (default: ISO-8859-1)
    'inputCharSet' => 'UTF-8',

    // set your output charset (default: ISO-8859-1)
    'outputCharSet' => 'ISO-8859-15',

    // convert to hex entities if no named entity exists (default: false)
    'hex' => true,
));

$text = $entityCoder->encode($text);
```

**Decode**

```
$entityCoder = new EntityCoder(array(
    // set named entity reference
    // -> 'special', 'xml', 'html' or an array of your own entities
    'entityReference' => 'html',

    // set your input charset (default: ISO-8859-1)
    'inputCharSet' => 'ISO-8859-15',

    // set your output charset (default: ISO-8859-1)
    'outputCharSet' => 'ASCII',

    // How to handle invalid characters
    // EXCEPTION  = throw an exception
    // CALLBACK   = call a callback
    // IGNORE     = replace by an empty character
    // SUBSTITUTE = substitute by an substitution character (default: "?")
    // TRANSLIT_* = convert to ASCII name with a fallback to one of the other actions
    'invalidCharAction' => EntityCoder::ACTION_SUBSTITUTE,

    // How to handle invalid entities
    // EXCEPTION  = throw an exception
    // CALLBACK   = call a callback
    // IGNORE     = replace by an empty character
    // SUBSTITUTE = substitute by an substitution character (default: "?")
    // ENTITY     = leave the entity as-is
    'invalidEntityAction' => EntityCoder::ACTION_ENTITY,
));

$text = $entityCoder->decode($text);
```

REQUIREMENTS
------------

[](#requirements)

This library requires PHP 5.3.0 or later. Additionally the php extension iconv is needed. (enabled by default)

ISSUES AND FEEDBACK
-------------------

[](#issues-and-feedback)

If you find code in this release behaving in an unexpected manner or contrary to its documented behavior, please create an issue in the GitHub issue tracker at:

LICENSE
-------

[](#license)

The files in this archive are released under the new BSD license. You can find a copy of this license in LICENSE.txt.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c0e3d92eaba3c58bb60a72d0113ad102ed0170fe1bd08c0eea83359e573c895f?d=identicon)[marc-mabe](/maintainers/marc-mabe)

---

Top Contributors

[![marc-mabe](https://avatars.githubusercontent.com/u/302689?v=4)](https://github.com/marc-mabe "marc-mabe (39 commits)")

### Embed Badge

![Health badge](/badges/marc-mabe-entity-coder/health.svg)

```
[![Health](https://phpackages.com/badges/marc-mabe-entity-coder/health.svg)](https://phpackages.com/packages/marc-mabe-entity-coder)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M170](/packages/hassankhan-config)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
