r5234 jmb - /trunk/libparserutils/build/conv.pl

netsurf at semichrome.net netsurf at semichrome.net
Thu Sep 4 18:01:18 BST 2008


Author: jmb
Date: Thu Sep  4 12:01:17 2008
New Revision: 5234

URL: http://source.netsurf-browser.org?rev=5234&view=rev
Log:
Perl script to convert Unicode mapping tables to C structures

Added:
    trunk/libparserutils/build/conv.pl   (with props)

Added: trunk/libparserutils/build/conv.pl
URL: http://source.netsurf-browser.org/trunk/libparserutils/build/conv.pl?rev=5234&view=auto
==============================================================================
--- trunk/libparserutils/build/conv.pl (added)
+++ trunk/libparserutils/build/conv.pl Thu Sep  4 12:01:17 2008
@@ -1,0 +1,49 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+# Convert Unicode mapping tables to C structures
+# Input files may be found at http://unicode.org/Public/MAPPINGS
+#
+# Usage: conv.pl <input_file>
+
+die "Usage: conv.pl <input_file>\n" if (scalar(@ARGV) != 1);
+
+my @table;
+
+open MAP, "<$ARGV[0]" or die "Failed opening $ARGV[0]: $!\n";
+
+while (<MAP>) {
+	next if (/^#/);
+
+	my @parts = split(/\s+/);
+
+	# Ignore ASCII part
+	next if (hex($parts[0]) < 0x80);
+
+	# Convert undefined entries to U+FFFF
+	if ($parts[1] =~ /^#/) {
+		push(@table, "0xFFFF");
+	} else {
+		push(@table, $parts[1]);
+	}
+}
+
+close MAP;
+
+# You'll have to go through and fix up the structure name
+print "static uint32_t ${ARGV[0]}[128] = {\n\t";
+
+my $count = 0;
+foreach my $item (@table) {
+	print "$item, ";
+	$count++;
+
+	if ($count % 8 == 0 && $count != 128) {
+		print "\n\t";
+	}
+}
+
+print "\n};\n\n";
+

Propchange: trunk/libparserutils/build/conv.pl
------------------------------------------------------------------------------
    svn:executable = *




More information about the netsurf-commits mailing list