Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
26
Task/Unicode-strings/Pluto/unicode-strings.pluto
Normal file
26
Task/Unicode-strings/Pluto/unicode-strings.pluto
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
require "uchar"
|
||||
require "gchar"
|
||||
local fmt = require("fmt")
|
||||
|
||||
local w = "voilà"
|
||||
local u = uchar.of(w)
|
||||
for i = 1, u:len() do
|
||||
io.write($"{u:get(i)} ") -- prints the 5 Unicode 'characters'
|
||||
end
|
||||
print($"\nThe length of {w} is {u:len()}")
|
||||
|
||||
print("\nIts code-points are:")
|
||||
fmt.lprint(u:tocodes(), " ", "") -- prints the code-points as numbers
|
||||
|
||||
print("\n\nIts bytes are: ")
|
||||
fmt.lprint(u:tobytes(), " ", "") -- prints the bytes as numbers
|
||||
|
||||
local zwe = "👨👩👧"
|
||||
local g = gchar.of(zwe)
|
||||
local codepoints = g:tocodes()
|
||||
local bytes = g:tobytes()
|
||||
|
||||
print($"\n\n{zwe} has:")
|
||||
fmt.print(" %d bytes: %s", #bytes, fmt.swrite(bytes, " ", ""))
|
||||
fmt.print(" %d code-points: %s", #codepoints, fmt.swrite(codepoints, " ", ""))
|
||||
fmt.print(" %d grapheme", g:len())
|
||||
Loading…
Add table
Add a link
Reference in a new issue