Search code examples
javautf-8utf-16

Re-encoding entire code base from UTF-16 to UTF-8


Does anyone have a good way to re-encode all the *.java file in a directory from UTF-16 to UTF-8?


Solution

  • Run this in your favorite POSIX compatible shell (while you're in the source directory):

    find -name "*.java" | while read f; do
       mv "$f" "$f.bak"
       iconv -f utf-16 -t utf-8 < "$f.bak" > "$f"
    done