Character codes: Difference between revisions

Content added Content deleted
(Added LFE example)
Line 880: Line 880:


=={{header|Scala}}==
=={{header|Scala}}==
[[Category:Scala Implementations]]
{{libheader|Scala}}
Scala supports unicode characters, but each character is UTF-16, so
Scala supports unicode characters, but each character is UTF-16, so
there is not a 1-to-1 relationship for supplementary character sets.
there is not a 1-to-1 relationship for supplementary character sets.
Line 885: Line 887:
Without worrying about supplemental character sets:
Without worrying about supplemental character sets:
<lang scala>scala> 'a' toInt
<lang scala>scala> 'a' toInt
res9: Int = 97
res2: Int = 97


scala> 97 toChar
scala> 97 toChar
res10: Char = a</lang>
res3: Char = a

scala> '\u0061'
res4: Char = a</lang>


Worrying about supplemental character sets, we need to test the "next" character as well:
Worrying about supplemental character sets, we need to test the "next" character as well: