TIP: Click on subject to list as thread! ANSI
echo: linux
to: HOLGER GRANHOLM
from: MAURICE KINAL
date: 2016-04-09 06:49:00
subject: I give up

Hey Holger!

Check out http://www.utf8-chartable.de/ and pay attention to the hex codes as
this will give you the two bytes you will require to convert to utf-8.  For
example the capital letter A with the ring above (Angstrom) corresponding to
cp437 hex code 0x8f becomes 0xc3 and 0x85 from your perspective.  Thus to read
in cp437 from a utf-8 text file all you have to do is convert any 0xc3 and 0x85
pair to 0x8f.

Really simple.  To make it even simpler get yourself sed for OS/2 and then the
above becomes;

  sed 's/\xc3\x85/\x8f/g' utf8.txt

To make the change permanent just add the -i switch to sed and then move
utf8.txt to cp437.txt.  Of course you'll have to repeat the above to make it
work for the other characters (total of six for Swedish) so that all will be
properly converted to/from utf8 to cp437.

A piece of cake.  ;-)

Of course this is all moot on a modern linux distribution since you'd have
access to glibc's iconv and converting to cp437 from utf-8 is as simple as;

  iconv -f utf8 -t cp437 utf8.txt -o cp437.txt

Way too easy.

Life is good,
Maurice

... Don't cry for me I have vi.
--- GNU bash, version 4.4.0(1)-rc1 (x86_64-atom-linux-gnu)
* Origin: Little Mikey's Brain - Ladysmith BC, Canada (1:153/7001.0)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.