Skip to content

Instantly share code, notes, and snippets.

@sudix
Created June 3, 2014 02:48
Show Gist options
  • Save sudix/3e8876db909da25549db to your computer and use it in GitHub Desktop.
Save sudix/3e8876db909da25549db to your computer and use it in GitHub Desktop.
Java(Scala)で全角波線などUTF-8からSHIFT_JIS変換時に文字化けするものを置換
/**
* UTF-8 to SHIFT_JIS
* 全角波線などUTF-8からSHIFT_JIS変換時に文字化けするものを置換
* 参考:http://d.hatena.ne.jp/sardine/20060214/p1
*/
def replaceInvalidChars(s: String): String =
s.replaceAll("\u301c", "\uff5e"). //~ (波ダッシュ)
replaceAll("\u2212", "\uff0d"). //- (マイナス)
replaceAll("\u2016", "\u2225") //∥ (二重垂直線)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment