Skip to content

Instantly share code, notes, and snippets.

@oquno
Created February 23, 2011 10:28
Show Gist options
  • Save oquno/840253 to your computer and use it in GitHub Desktop.
Save oquno/840253 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'kconv'
f = open(ARGV[0])
read = f.read
f.close
read = read.kconv(6, Kconv.guess(read))
read = read.gsub(/charset=[^"\s]+/i, "charset=utf-8")
read = read.gsub(/encoding="[^"\s]+"/i, "encoding=\"utf-8\"")
f = open(ARGV[0], "w")
f.write(read)
f.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment