#!/usr/bin/perl use strict; open IN, "encodings.in" or die "Can't open in\n"; open out, ">encodings.c" or die "Can't open out\n"; my @qwritingSystems = ( "Any", "Latin", "Greek", "Cyrillic", "Armenian", "Hebrew", "Arabic", "Syriac", "Thaana", "Devanagari", "Bengali", "Gurmukhi", "Gujarati", "Oriya", "Tamil", "Telugu", "Kannada", "Malayalam", "Sinhala", "Thai", "Lao", "Tibetan", "Myanmar", "Georgian", "Khmer", "SimplifiedChinese", "TraditionalChinese", "Japanese", "Korean", "Vietnamese", "Yi", "Tagalog", "Hanunoo", "Buhid", "Tagbanwa", "Limbu", "TaiLe", "Braille", "Other" ); my $writingSystemsCount = @qwritingSystems; my $num = 0; my @xlfd = (); my @mib = (); my @writingSystems = (); my $i; while () { chomp; s/#.*//; if ( index( $_, ' ' ) > -1 ) { chomp; my @line = split( / /, $_ ); $xlfd[$num] = $line[0]; $mib[$num] = $line[1]; $writingSystems[$num] = $line[2]; $num = $num + 1; } } print out "struct XlfdEncoding {\n const char *name;\n int id;\n int mib;\n};\n\n"; print out "static const XlfdEncoding xlfd_encoding[] = {\n"; $i = 0; while( $i < $num ) { print out " { \"".$xlfd[$i]."\", ".$i.", ".$mib[$i]." },\n"; $i = $i + 1; } print out " { 0, 0, 0 }\n};\n\n"; close out;