Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
12
Task/Unicode-strings/Julia/unicode-strings.julia
Normal file
12
Task/Unicode-strings/Julia/unicode-strings.julia
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function surround(string ; border = :default)
|
||||
|
||||
ve, ho, ul, ur, dl, dr =
|
||||
border == :bold ? ("\u2503","\u2501","\u250F","\u2513","\u2517","\u251b") :
|
||||
border == :double? ("\u2551","\u2550","\u2554","\u2557","\u255a","\u255d") :
|
||||
border == :dotted? ("\u254e","\u254c","\u250c","\u2510","\u2514","\u2518") :
|
||||
("\u2502","\u2500","\u250c","\u2510","\u2514","\u2518")
|
||||
|
||||
println(ul,ho^length(string),ur,"\n",
|
||||
ve, string ,ve,"\n",
|
||||
dl,ho^length(string),dr)
|
||||
end
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
sub prefix:<∛> ($𝕏) { $𝕏 ** (1/3) }
|
||||
sub prefix:<∛> ($#56655;) { $#56655; ** (1/3) }
|
||||
say ∛27; # prints 3
|
||||
|
|
|
|||
17
Task/Unicode-strings/Racket/unicode-strings.rkt
Normal file
17
Task/Unicode-strings/Racket/unicode-strings.rkt
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#lang racket
|
||||
|
||||
;; Unicode in strings, using ascii
|
||||
"\u03bb" ; -> "λ"
|
||||
;; and since Racket source code is read in UTF-8, Unicode can be used
|
||||
;; directly
|
||||
"λ" ; -> same
|
||||
|
||||
;; The same holds for character constants
|
||||
#\u3bb ; -> #\λ
|
||||
#\λ ; -> same
|
||||
|
||||
;; And of course Unicode can be used in identifiers,
|
||||
(define √ sqrt)
|
||||
(√ 256) ; -> 16
|
||||
;; and in fact the standard language makes use of some of these
|
||||
(λ(x) x) ; -> an identity function
|
||||
28
Task/Unicode-strings/Scala/unicode-strings.scala
Normal file
28
Task/Unicode-strings/Scala/unicode-strings.scala
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue