Created
October 9, 2016 03:54
-
-
Save todokr/ed7974bd5ff8366d457f3bf39f6c27a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File | |
import com.github.tototoshi.csv.CSVWriter | |
object Mojibake extends App { | |
val f = new File("./mojibake-patterns.csv") | |
val writer = CSVWriter.open(f) | |
val targetString = "入れ替わってる〜!?" | |
val encodings = List("UTF-8", "EUC_JP", "Shift-JIS", "ISO-2022-JP") | |
writer.writeRow(List("変換元", "変換先", "結果")) | |
encodings.map(x => (x, encodings)).toMap.foreach { case (from, to) => | |
to.foreach { _to => | |
val row = List(from, _to, new String(targetString.getBytes(from), _to)) | |
writer.writeRow(row) | |
} | |
} | |
writer.close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment