0.01
No commit activity in last 3 years
No release in over 3 years
Convert a string's encoding to utf8, whithout caring which encoding used before converting.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

string_utf8

turn ruby strings encoding to unicode (utf-8) from any other

install

gem install string_utf8

usage

require "string/utf8"

str = read_string_from_somewhere
# =>  "\xD6\xD0\xCE\xC4"

str.utf8!
# => "中文"

p $enc
# => "gb18030"

tech detail

This gem adds a monkey patch to String class, adding a method naming 'utf8!'.

It guesses what encoding the string is using, and force it to use utf-8 encoding.

You can get what former encoding the string is using by checking $enc