Re: Pattern matching Byte on hex integer literal

On Wed, Sep 21, 2011 at 9:22 PM, Derek Williams wrote:
> try this:
>
> def getCharset(bytes: Array[Byte]): String = {
>   (bytes(0) + 256) % 256 match {
>     case 0xFF => if (bytes(1) == 0xFE) "UTF-16LE" else txtCharset
>     case 0xFE => if (bytes(1) == 0xFF) "UTF-16BE" else txtCharset
>     case 0XEF => if (bytes(1) == 0xBB && bytes(2) == 0xBF) "UTF-8"
>                  else txtCharset
>     case _    => txtCharset
>   }
> }

Woops, that wont work, the 'if' statements will still fail.

Copyright © 2013 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland