Unicode strings: Difference between revisions
Content added Content deleted
(Added Erlang) |
|||
Line 795: | Line 795: | ||
* Racket includes additional related functionality, like some Unicode functions (normalization etc), and IO encoding based on iconv to do IO of many other encodings. |
* Racket includes additional related functionality, like some Unicode functions (normalization etc), and IO encoding based on iconv to do IO of many other encodings. |
||
=={{header|Scala}}== |
|||
[[Category:Scala Implementations]] |
|||
{{libheader|Scala}} |
|||
<lang scala>object UTF8 extends App { |
|||
def charToInt(s: String) = { |
|||
def charToInt0(c: Char, next: Char): Option[Int] = (c, next) match { |
|||
case _ if (c.isHighSurrogate && next.isLowSurrogate) => |
|||
Some(java.lang.Character.toCodePoint(c, next)) |
|||
case _ if (c.isLowSurrogate) => None |
|||
case _ => Some(c.toInt) |
|||
} |
|||
if (s.length > 1) charToInt0(s(0), s(1)) else Some(s.toInt) |
|||
} |
|||
def intToChars(n: Int) = java.lang.Character.toChars(n).mkString |
|||
println('\uD869'.isHighSurrogate + " " + '\uDEA5'.isLowSurrogate) |
|||
println(charToInt("\uD869\uDEA5")) |
|||
val b = "\uD869\uDEA5" |
|||
println(b) |
|||
val c = "\uD834\uDD1E" |
|||
println(c) |
|||
val a = "$abcde¢£¤¥©ÇßçIJijŁłʒλπ•₠₡₢₣₤₥₦₧₨₩₪₫€₭₮₯₰₱₲₳₴₵₵←→⇒∙⌘☺☻ア字文𪚥". |
|||
map(c => "%s\t\\u%04X".format(c, c.toInt)).foreach(println) |
|||
}</lang> |
|||
{{out}} |
|||
<pre style="height:20ex;overflow:scroll">true true |
|||
Some(173733) |
|||
𪚥 |
|||
𝄞 |
|||
$ \u0024 |
|||
a \u0061 |
|||
b \u0062 |
|||
c \u0063 |
|||
d \u0064 |
|||
e \u0065 |
|||
¢ \u00A2 |
|||
£ \u00A3 |
|||
¤ \u00A4 |
|||
¥ \u00A5 |
|||
© \u00A9 |
|||
Ç \u00C7 |
|||
ß \u00DF |
|||
ç \u00E7 |
|||
IJ \u0132 |
|||
ij \u0133 |
|||
Ł \u0141 |
|||
ł \u0142 |
|||
ʒ \u0292 |
|||
λ \u03BB |
|||
π \u03C0 |
|||
• \u2022 |
|||
₠ \u20A0 |
|||
₡ \u20A1 |
|||
₢ \u20A2 |
|||
₣ \u20A3 |
|||
₤ \u20A4 |
|||
₥ \u20A5 |
|||
₦ \u20A6 |
|||
₧ \u20A7 |
|||
₨ \u20A8 |
|||
₩ \u20A9 |
|||
₪ \u20AA |
|||
₫ \u20AB |
|||
€ \u20AC |
|||
₭ \u20AD |
|||
₮ \u20AE |
|||
₯ \u20AF |
|||
₰ \u20B0 |
|||
₱ \u20B1 |
|||
₲ \u20B2 |
|||
₳ \u20B3 |
|||
₴ \u20B4 |
|||
₵ \u20B5 |
|||
₵ \u20B5 |
|||
← \u2190 |
|||
→ \u2192 |
|||
⇒ \u21D2 |
|||
∙ \u2219 |
|||
⌘ \u2318 |
|||
☺ \u263A |
|||
☻ \u263B |
|||
ア \u30A2 |
|||
字 \u5B57 |
|||
文 \u6587 |
|||
? \uD869 |
|||
? \uDEA5 |
|||
\uF8FF |
|||
</pre> |
|||
=={{header|Seed7}}== |
=={{header|Seed7}}== |
||
The Unicode encoding of Seed7 [http://seed7.sourceforge.net/manual/types.htm#char characters] and |
The Unicode encoding of Seed7 [http://seed7.sourceforge.net/manual/types.htm#char characters] and |