Jump to content

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

m
→‎version 2: changed EOF handling
(added REXX version 2 (show my understanding of this task))
m (→‎version 2: changed EOF handling)
Line 101:
* read one utf8 character at a time
* see http://de.wikipedia.org/wiki/UTF-8#Kodierung
* sorry this is in German but the encoding table should be obvious
*--------------------------------------------------------------------*/
oid='utf8.txt';'erase' oid /* first create file containing utf8 chars*/
Line 111 ⟶ 110:
Call lineout oid
fid='utf8.txt' /* then read it and show the contents */
Do Until c8='EOF'
Do While chars(fid)>0
c8=get_utf8char(fid)
Say left(c8,4) c2x(c8)
End
Say 'EOF'
Exit
 
get_utf8char: Procedure
Parse Arg f
If chars(f)=0 Then
Return 'EOF'
c=charin(f)
b=c2b(c)
Line 143:
€ E282AC
𝄞 F09D849E
EOF 454F46</pre>
 
=={{header|Ruby}}==
2,299

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.