Welcome to mirror list, hosted at ThFree Co, Russian Federation.

package.scala « util « rorschach « getbootstrap « com « scala « main « src - github.com/twbs/rorschach.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0768e9f604c2f6f5e2ce3371927f41bd1f1b77de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package com.getbootstrap.rorschach

import java.nio.charset.Charset
import scala.util.Try

package object util {
  private val utf8 = Charset.forName("UTF-8")

  implicit class Utf8String(str: String) {
    def utf8Bytes: Array[Byte] = str.getBytes(utf8)
  }

  implicit class Utf8ByteArray(bytes: Array[Byte]) {
    def utf8String: Try[String] = Try { new String(bytes, utf8) }
  }
}