-
Notifications
You must be signed in to change notification settings - Fork 1
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 #106 from Starchasers/fix/plaintext-encoding
fix plaintext files encoding
- Loading branch information
Showing
5 changed files
with
69 additions
and
28 deletions.
There are no files selected for viewing
Empty file.
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
20 changes: 20 additions & 0 deletions
20
spring-app/src/main/kotlin/pl/starchasers/up/service/CharsetDetectionService.kt
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,20 @@ | ||
package pl.starchasers.up.service | ||
|
||
import com.ibm.icu.text.CharsetDetector | ||
import org.springframework.stereotype.Service | ||
import java.io.InputStream | ||
|
||
interface CharsetDetectionService { | ||
fun detect(inputStream: InputStream): String | ||
} | ||
|
||
@Service | ||
class CharsetDetectionServiceImpl : CharsetDetectionService { | ||
override fun detect(inputStream: InputStream): String { | ||
val detector = CharsetDetector() | ||
detector.setDeclaredEncoding("utf-8") | ||
detector.setText(inputStream) | ||
return detector.detect().name | ||
} | ||
|
||
} |
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