如何将此字符串的调查规则转换为
Scala中的UTF-8?
我尝试过这些道路,但不起作用:
scala> val text = "the surveyÂ’s rules"
text: String = the surveyÂ’s rules
scala> scala.io.Source.fromBytes(text.getBytes(), "UTF-8").mkString
res17: String = the surveyÂ’s rules
scala> new String(text.getBytes(),"UTF8")
res21: String = the surveyÂ’s rules
好的,我已经以这种方式解决了.不是转换,而是简单的阅读
implicit val codec = Codec("US-ASCII").onMalformedInput(CodingErrorAction.IGNORE).onUnmappableCharacter(CodingErrorAction.IGNORE)
val src = Source.fromFile(new File (folderDestination + name + ".csv"))
val src2 = Source.fromFile(new File (folderDestination + name + ".csv"))
val reader = CSVReader.open(src.reader())