Created
June 3, 2014 02:48
-
-
Save sudix/3e8876db909da25549db to your computer and use it in GitHub Desktop.
Java(Scala)で全角波線などUTF-8からSHIFT_JIS変換時に文字化けするものを置換
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
/** | |
* 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