# Encode a string into UTF-8, ready for XML

**URL:** <https://www.ruby-forum.com/t/encode-a-string-into-utf-8-ready-for-xml/130744>\
**Category:** Rails\
**Created:** [March 2, 2008, 11:33pm UTC](https://www.ruby-forum.com/t/encode-a-string-into-utf-8-ready-for-xml/130744 "2008-03-02T23:33:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![crenner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/278dde/32.png) [@crenner](https://www.ruby-forum.com/u/crenner)\
**Post date:** [March 2, 2008, 11:33pm UTC](https://www.ruby-forum.com/t/encode-a-string-into-utf-8-ready-for-xml/130744/1 "2008-03-02T23:33:01Z")

</div>

Hi

i need to encode a string,ready for insertion into an xml document. I  
think it needs to be in UTF-8

Is there a simple ruby method for doing this?

Thanks  
Chris
