Read a file character by character/UTF8: Difference between revisions

Content added Content deleted
m (Added Sidef)
Line 664: Line 664:
got character a [U+61]
got character a [U+61]
got character ă [U+103]
got character ă [U+103]
got character € [U+20ac]
got character ⼥ [U+2f25]
</pre>

=={{header|Sidef}}==
<lang ruby>var file = File('input.txt') # the input file contains: "aă€⼥"
var fh = file.open_r # equivalent with: file.open('<:utf8')
fh.each_char { |char|
printf("got character #{char} [U+%04x]\n", char.ord)
}</lang>
{{out}}
<pre>
got character a [U+0061]
got character ă [U+0103]
got character € [U+20ac]
got character € [U+20ac]
got character ⼥ [U+2f25]
got character ⼥ [U+2f25]