Idiomatically determine all the characters that can be used for symbols: Difference between revisions
Idiomatically determine all the characters that can be used for symbols (view source)
Revision as of 12:18, 4 September 2019
, 4 years ago→{{header|Phix}}
Line 383:
end function
function check(integer lo, hi)
integer ng1 = 0, ng2 = 0
for ch=
printf(1,"checking %d/255...\r",ch)▼
ng2 += 1
else▼
if run(
if run("_"&c)==0 then ok2 &= c else ng2 += 1 end if
end if
end for
return {{ng1,length(ok1),ok1},
{ng2,length(ok2),ok2}}
end function
sequence r = check(0,127)
printf(1,"ansi characters:\n===============\n")
printf(1,"1st character: %d NG, %d OK %s\n",r[1])
printf(1,"2nd..nth char: %d NG, %d OK %s\n\n",r[2])
r = check(128,255)
integer ok8 = 0, ng8 = 0
sequence good = ""
for i=#80 to #10FFFF do
if i<#D800 or i>#DFFF then
string utf8 = utf32_to_utf8({i})
bool ok = true
if not find(utf8[1],r[1][3]) then
ok = false
▲ else
for j=2 to length(utf8) do
if not find(utf8[j],r[2][3]) then
ok = false
exit
end if
end for
end if
if ok then
ok8 += 1
good &= utf8&", "
else
ng8 += 1
end if
end if
end for
printf(1,"
printf(1,"
if platform()=LINUX then
-- (comes out gibberish on a windows console...)
printf(1,"%s\n",{good})
end if</lang>
{{out}}
<pre>
ansi characters:
===============
1st character: 75 NG, 53 OK ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
</pre>▼
2nd..nth char: 65 NG, 63 OK 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
utf8 characters:
===============
good:48, bad:1111888
, Έ, Δ, Κ, Σ, λ, π, ψ, ϔ, Ϛ, ϣ, ϻ, , , —, ‚, ‣, ※, ∀, ∈, ∔, √, ∣, ∻, ─, ┈, └, ┚, ┣, ┻, ⚀, ⚈, ⚔, ⚚, ⚣, ⚻, ⣀, ⣈, ⣔, ⣚, ⣣, ⣻, ⻀, ⻈, ⻔, ⻚, ⻣, ,
▲</pre>
Note that ptok.e (part of the compiler) currently contains the following:
<lang Phix>charset[#80] = LETTER -- more unicode
Line 415 ⟶ 458:
charset[#CF] = LETTER
charset[#E2] = LETTER</lang>
If that is extended (with more utf-8 handling) then obviously the output will change.<br>
I am a little surprised at just how few ad-hoc utf8 characters have been supported so far.
=={{header|Python}}==
|