|
Revision 365, 0.7 kB
(checked in by calh, 9 months ago)
|
build windows installer strings/config files from a single template, substituting strings from the locale folder. more ja-jp stuff in the makefile. convert files to utf-16 on the fly (only have utf-8 in trunk).
|
| Line | |
|---|
| 1 |
#!/usr/bin/perl |
|---|
| 2 |
|
|---|
| 3 |
use warnings; |
|---|
| 4 |
use strict; |
|---|
| 5 |
|
|---|
| 6 |
open F, $ARGV[0] or die $!; |
|---|
| 7 |
|
|---|
| 8 |
print chr(255).chr(254); # BOM |
|---|
| 9 |
|
|---|
| 10 |
while (my $line = <F>){ |
|---|
| 11 |
|
|---|
| 12 |
my @chars = split //, $line; |
|---|
| 13 |
|
|---|
| 14 |
while (scalar @chars){ |
|---|
| 15 |
|
|---|
| 16 |
my $b1 = ord shift @chars; |
|---|
| 17 |
my $val = 0; |
|---|
| 18 |
|
|---|
| 19 |
if (($b1 >= 0) && ($b1 <= 0x7F)){ |
|---|
| 20 |
$val = $b1; |
|---|
| 21 |
} |
|---|
| 22 |
|
|---|
| 23 |
if (($b1 >= 0xC0) && ($b1 <= 0xDF)){ |
|---|
| 24 |
my $b2 = ord shift @chars; |
|---|
| 25 |
|
|---|
| 26 |
$val = ((0x1F & $b1) << 6) | (0x3F & $b2); |
|---|
| 27 |
} |
|---|
| 28 |
|
|---|
| 29 |
if (($b1 >= 0xE0) && ($b1 <= 0xEF)){ |
|---|
| 30 |
my $b2 = ord shift @chars; |
|---|
| 31 |
my $b3 = ord shift @chars; |
|---|
| 32 |
|
|---|
| 33 |
$val = ((0xF & $b1) << 12) | ((0x3F & $b2) << 6) | (0x3F & $b3); |
|---|
| 34 |
} |
|---|
| 35 |
|
|---|
| 36 |
if ($b1 > 0xEF){ |
|---|
| 37 |
$val = ord '?'; |
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
print chr ($val & 0x00FF); |
|---|
| 41 |
print chr (($val & 0xFF00) >> 8); |
|---|
| 42 |
} |
|---|
| 43 |
} |
|---|
| 44 |
close F; |
|---|