Jump to content

Unicode strings: Difference between revisions

→‎{{header|Julia}}: greatly simplify
No edit summary
(→‎{{header|Julia}}: greatly simplify)
Line 639:
 
=={{header|Julia}}==
Non-ASCII strings in Julia are UTF8-encoded by default, and Unicode identifiers are also supported:
<lang Julia>function surround(string ; border = :default)
<lang Julia>
 
julia> 四十二 = "voilà";
ve, ho, ul, ur, dl, dr =
julia> println(四十二)
border == :bold ? ("\u2503","\u2501","\u250F","\u2513","\u2517","\u251b") :
voilà
border == :double? ("\u2551","\u2550","\u2554","\u2557","\u255a","\u255d") :
end</lang>
border == :dotted? ("\u254e","\u254c","\u250c","\u2510","\u2514","\u2518") :
And you can also specify unicode characters by ordinal:
("\u2502","\u2500","\u250c","\u2510","\u2514","\u2518")
<lang Julia>
 
julia>println(ul,ho^length(string),ur,"\nu2708",)
ve, string ,ve,"\n",
</lang>
dl,ho^length(string),dr)
end</lang>
{{out}}
<pre>julia> for (value, style) in {("♡", :dotted),("♠", :bold)}
surround(value, border = style)
end
┌╌┐
╎♡╎
└╌┘
┏━┓
┃♠┃
┗━┛</pre>
 
=={{header|Locomotive Basic}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.