mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-01-30 03:09:22 +01:00
Recommended use of BOMInputStream (#3938)
This commit is contained in:
committed by
GitHub
parent
5fc3dd74a8
commit
6b145ea760
@@ -91,7 +91,10 @@ object StringUtil {
|
||||
* And if given bytes contains UTF-8 BOM, it's removed from returned string.
|
||||
*/
|
||||
def convertFromByteArray(content: Array[Byte]): String =
|
||||
IOUtils.toString(new BOMInputStream(new java.io.ByteArrayInputStream(content)), detectEncoding(content))
|
||||
IOUtils.toString(
|
||||
BOMInputStream.builder().setInputStream(new java.io.ByteArrayInputStream(content)).setInclude(true).get(),
|
||||
detectEncoding(content)
|
||||
)
|
||||
|
||||
def detectEncoding(content: Array[Byte]): String = {
|
||||
val detector = new UniversalDetector(null)
|
||||
|
||||
Reference in New Issue
Block a user