DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Convert A UTF-8 String To ISO-8859-1
Convert a utf string to iso, used this when generating a pdf with pdf-writer in Rails, all my text is UTF8 but pdf-writer does not support this.
#add this to environment.rb #call to_iso on any UTF8 string to get a ISO string back #example : "CÃ©dez le passage aux franÃ§ais".to_iso class String require 'iconv' #this line is not needed in rails ! def to_iso Iconv.conv('ISO-8859-1', 'utf-8', self) end end