#!/usr/bin/perl -w # Encode curve data from marcille17.c as ASCII characters. use strict; my @points = ( 15,70, 11,72, 10,79, 16,84, 20,87, 30,85, 29,79, 28,74, 19,68, 15,70, 0, 59,65, 59,68, 60,74, 65,76, 70,78, 75,71, 71,65, 68,61, 59,61, 59,65, 0, 37,8, 46,8, 45,2, 58,4, 71,6, 74,16, 76,31, 77,38, 84,39, 77,47, 64,58, 20,38, 17,26, 14,14, 25,8, 37,8, 0, 29,38, 23,33, 19,26, 24,23, 29,20, 37,28, 43,35, 48,41, 48,46, 57,49, 57,50, 57,52, 56,54, 65,57, 59,67, 55,70, 44,78, 31,77, 23,67, 12,51, 29,41, 29,38, 0, 19,75, 20,76, 21,77, 23,77, 24,74, 25,72, 30,72, 31,71, 30,69, 29,68, 23,68, 21,71, 19,75, 0, 59,70, 61,70, 62,69, 63,68, 64,68, 66,70, 66,71, 65,73, 61,75, 59,75, 58,74, 58,71, 59,70, 0, 59,70, 60,71, 60,74, 59,75, 54,75, 52,72, 50,69, 51,67, 52,66, 54,66, 55,68, 56,70, 59,70, 0, 0 ); # Find offset that minimizes undesirable characters. my $best_offset = 33; my $min_escape = scalar @points; for(my $offset = 33; $offset < 60; $offset++) { my $slash = 0; my $quote = 0; my $out_of_bounds = 0; foreach my $c (@points) { if( $c + $offset >= 127 ) { $out_of_bounds++; } else { if( chr($c + $offset) eq '\\' ) { $slash++; } elsif( chr($c + $offset) eq '"' ) { $quote++; } } } if( $out_of_bounds == 0 ) { print "offset = $offset, slash = $slash, quote = $quote\n"; my $escape = $slash + $quote; if( $min_escape > $escape ) { $min_escape = $escape; $best_offset = $offset; } } } print "best offset = $best_offset\n"; foreach my $c (@points) { print chr($c + $best_offset); } print "\n";