# HTMLEntities 4.0.0

**URL:** <https://www.ruby-forum.com/t/htmlentities-4-0-0/89011>\
**Category:** Ruby\
**Created:** [March 16, 2007, 2:20pm UTC](https://www.ruby-forum.com/t/htmlentities-4-0-0/89011 "2007-03-16T14:20:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [March 16, 2007, 2:20pm UTC](https://www.ruby-forum.com/t/htmlentities-4-0-0/89011/1 "2007-03-16T14:20:21Z")

</div>

I wrapped up and released a new version of HTMLEntities last night.  
The version number has inflated to 4.0.0 to reflect some significant  
changes in the interface.

## What is it?

HTMLEntities is a simple library to facilitate encoding and decoding  
of named (ý and so on) or numerical ({ or Ī)  
entities in HTML and XHTML documents.

## What’s changed?

This update has many requested improvements and fixes:

- Now understands all the entities referred to in the XHTML 1.0 DTD  
(253 entities compared with 131 in version 3.0.1).
- Calls to\_s on parameters to play nicely with Rails 1.2.1.
- Entity mapping data is now lazily loaded.
- New instantiation-based interface (but legacy interface is preserved  
for compatibility).
- Handles HTML4 as well as XHTML1 (the former lacks the ' entity).
- Encodes basic entities numerically when :basic isn’t specified and  
:decimal or :hexadecimal is.
- Performs a maximum of two gsub passes instead of three when  
encoding, which should be more efficient on long strings.

## What about existing code?

Using HTMLEntities already? You probably don’t need to change  
anything. The old syntax still works, although it should be considered  
deprecated. However, HTMLEntities is now a class instead of a module,  
so if you have been including HTMLEntities and calling the methods  
directly, you’ll need to make a few changes.

## Learn more

Examples and documentation are available at  
[http://htmlentities.rubyforge.org/](http://htmlentities.rubyforge.org/)

## Get it

gem install htmlentities

Or grab a tarball here:  
[http://rubyforge.org/frs/?group\_id=1462](http://rubyforge.org/frs/?group_id=1462)

## Credits

Thanks to Dallas DeVries, Johan Duflost, Paul W., Marcos Kuhns and  
Jaime I. for bug reports and feature requests.
