-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #753 from kusumotolab/fix-patch-encoding
patchのエンコーディングのバグを修正
- Loading branch information
Showing
10 changed files
with
243 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package example; | ||
|
||
public class Foo { | ||
|
||
/** | ||
* 2つの整数のうち大きい整数を返す | ||
* | ||
* @param n 整数 | ||
* @param m 整数 | ||
* @return n, mのうち大きい整数 | ||
*/ | ||
public int max(int n, int m) { | ||
if (n < m) { | ||
return m; | ||
} else { | ||
return n; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package example; | ||
|
||
public class Foo { | ||
|
||
/** | ||
* 2つの整数のうち大きい整数を返す | ||
* | ||
* @param n 整数 | ||
* @param m 整数 | ||
* @return n, mのうち大きい整数 | ||
*/ | ||
public int max(int n, int m) { | ||
if (n < m) { | ||
return m; | ||
} else { | ||
return n; | ||
} | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
src/main/java/jp/kusumotolab/kgenprog/CharsetDetector.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package jp.kusumotolab.kgenprog; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.Charset; | ||
import java.nio.file.Path; | ||
import org.mozilla.universalchardet.UniversalDetector; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* ファイルの文字コードを調べるクラス | ||
*/ | ||
public class CharsetDetector { | ||
|
||
private final static Logger log = LoggerFactory.getLogger(CharsetDetector.class); | ||
|
||
/** | ||
* 与えられたファイルの文字コードを調べる. | ||
* 文字コードがわからなかった場合はデフォルトの文字コードを返す | ||
* | ||
* @param path 文字コードを調べたいファイル | ||
* @return ファイルの文字コード | ||
*/ | ||
public Charset detect(final Path path) { | ||
try { | ||
final String charsetName = UniversalDetector.detectCharset(path); | ||
return charsetName != null ? Charset.forName(charsetName) : Charset.defaultCharset(); | ||
} catch (final IOException e) { | ||
log.error(e.getMessage(), e); | ||
return Charset.defaultCharset(); | ||
} | ||
} | ||
} |
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
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
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
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
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