source: git/lib/fixmsgs.pl @ d4d6909

add-show-splaysline_contentsproj-api-updatestereosvn/github/mastersvn/origin/mastersvn/tags/1.2.3svn/tags/1.2.4svn/tags/1.2.5svn/trunk
Last change on this file since d4d6909 was ffe7b714, checked in by Olly Betts <olly@…>, 11 years ago

lib/fixmsgs.pl: Update to fix UTF-8 rather than ISO8859-1.

git-svn-id: file:///home/survex-svn/survex/trunk@3581 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

  • Property mode set to 100755
File size: 676 bytes
Line 
1#!/usr/bin/perl -w
2require 5.008;
3use open ':encoding(utf8)';
4use strict;
5
6use integer;
7
8my @ent = ();
9for (128..65536) {
10   $ent[$_] = "#$_";
11}
12
13open ENT, "named-entities.txt" or die $!;
14while (<ENT>) {
15   my ($e, $v) = /^(\w+),(\d+)/;
16   $ent[$v] = $e;
17}
18close ENT;
19
20while (<>) {
21   if (/^\s*#/) {
22      print;
23      next;
24   }
25   
26   my ($pre, $msg) = /^([-\w,]+:\s*\d+\s+)(.*)/;
27
28   $msg =~ s/([\x{80}-\x{ffff}])/"&".$ent[ord($1)].";"/ge;
29
30   $msg =~ s/'\%s'/`%s'/g;
31   $msg =~ s/^([^`']* )\%s'/$1`%s'/;
32   $msg =~ s/^([^`']* `\%s'[^`']* )\%s'/$1`%s'/;
33   $pre =~ s/: (\d\d\d\b)/:$1/;
34   $pre =~ s/:(\d\d\b)/: $1/;
35   $pre =~ s/: ?(\d\b)/:  $1/;
36
37   print "$pre$msg\n";
38}
Note: See TracBrowser for help on using the repository browser.