Convert A UTF-8 String To ISO-8859-1
Join the DZone community and get the full member experience.Join For Free
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
UTF-8 Strings Convert (command)
Opinions expressed by DZone contributors are their own.