UTF-8 encode and decode: Difference between revisions

Realize in F#
(Realize in F#)
Line 350:
𝄞 F0 9D 84 9E U+1D11E</pre>
 
=={{header|F_Sharp|F#}}==
<lang fsharp>
// Unicode character point to UTF8. Nigel Galloway: March 19th., 2018
let fN g = match List.findIndex (fun n->n>g) [0x80;0x800;0x10000;0x110000] with
|0->[g]
|1->[0xc0+(g&&&0x7c0>>>6);0x80+(g&&&0x3f)]
|2->[0xe0+(g&&&0xf000>>>12);0x80+(g&&&0xfc0>>>6);0x80+(g&&&0x3f)]
|_->[0xf0+(g&&&0x1c0000>>>18);0x80+(g&&&0x3f000>>>12);0x80+(g&&&0xfc0>>>6);0x80+(g&&&0x3f)]
</lang>
{{out}}
<pre>
for n in fN 0x41 do printf "%x " n -> 41
for n in fN 0xf6 do printf "%x " n -> c3 b6
for n in fN 0x416 do printf "%x " n -> d0 96
for n in fN 0x20ac do printf "%x " n -> e2 82 ac
for n in fN 0x1d11e do printf "%x " n -> f0 9d 84 9e
</pre>
=={{header|Go}}==
===Implementation===
2,172

edits