开发者

Convert String to Byte

I need to convert a Char to an Byte. I 开发者_JS百科belief this should be very simple but i don't find a nice solution.

0x7A.toChar => 'z'
'z'.???? => 0x7A

Edit:

I'm to tired... 'z'.toByte => 0x7A


scala> 'z'.toByte
res0: Byte = 122

scala> res0.toChar
res1: Char = z

Note that a Char in Scala (and Java) is Unicode UTF-16 which means that it is 2 bytes. You might lose information!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜