Revision: 10314 https://osdn.net/projects/ttssh2/scm/svn/commits/10314 Author: zmatsuo Date: 2022-10-15 23:38:44 +0900 (Sat, 15 Oct 2022) Log Message: ----------- 改行変換、BOM削除 Modified Paths: -------------- trunk/teraterm/teraterm/unicode/get_emoji_table.pl trunk/teraterm/teraterm/unicode/get_f_w_a.pl -------------- next part -------------- Modified: trunk/teraterm/teraterm/unicode/get_emoji_table.pl =================================================================== --- trunk/teraterm/teraterm/unicode/get_emoji_table.pl 2022-10-13 14:27:25 UTC (rev 10313) +++ trunk/teraterm/teraterm/unicode/get_emoji_table.pl 2022-10-15 14:38:44 UTC (rev 10314) @@ -1,71 +1,71 @@ -#!/usr/bin/perl -use utf8; -use strict; -use warnings; - -binmode STDOUT, ":utf8"; - -sub output { - my ($fh, $start, $end, $comment) = @_; - - if ($start >= 0x80) { - printf($fh "{ 0x%06x, 0x%06x }, // %s\n", $start, $end, $comment); - } -} - -my $fname_out = "unicode_emoji.tbl"; -if (@ARGV == 1) { - $fname_out = $ARGV[0]; -} - -my $src_file = "emoji-data.txt"; -open(my $fh, "<:utf8", $src_file) || die "Cannot open $src_file."; -open(my $fh_out, ">:crlf:utf8", $fname_out) || die "Cannot open $fname_out."; -printf($fh_out "\x{feff}"); # BOM -printf($fh_out "// $src_file\n"); - -my $block = 0; -my $start; -my $end; -my $comment; -my $ostart; -my $ocomment; -my $oend = 0; -while(my $a = <$fh>) { - if ($a =~ /^# ======/) { - $block = $block + 1; - if ($block == 2) { - last; - } - } - - if ($a =~ /^([0-9A-F]+)\.\.([0-9A-F]+).+\)\s+(.+)$/) { - $start = hex $1; - $end = hex $2; - $comment = $3; - } elsif ($a =~ /^([0-9A-F]+).+\)\s+(.+)$/) { - $start = hex $1; - $end = $start; - $comment = $2; - } else { - next; - } - - if ($oend == 0) { - $ostart = $start; - $oend = $end; - $ocomment = $comment; - } elsif ($oend + 1 == $start) { - # combine - $oend = $end; - } else { - output($fh_out, $ostart, $oend, $ocomment); - $ostart = $start; - $oend = $end; - $ocomment = $comment; - } -} - -if ($oend != 0) { - output($fh_out, $ostart, $oend, $ocomment); -} +#!/usr/bin/perl +use utf8; +use strict; +use warnings; + +binmode STDOUT, ":utf8"; + +sub output { + my ($fh, $start, $end, $comment) = @_; + + if ($start >= 0x80) { + printf($fh "{ 0x%06x, 0x%06x }, // %s\n", $start, $end, $comment); + } +} + +my $fname_out = "unicode_emoji.tbl"; +if (@ARGV == 1) { + $fname_out = $ARGV[0]; +} + +my $src_file = "emoji-data.txt"; +open(my $fh, "<:utf8", $src_file) || die "Cannot open $src_file."; +open(my $fh_out, ">:crlf:utf8", $fname_out) || die "Cannot open $fname_out."; +printf($fh_out "\x{feff}"); # BOM +printf($fh_out "// $src_file\n"); + +my $block = 0; +my $start; +my $end; +my $comment; +my $ostart; +my $ocomment; +my $oend = 0; +while(my $a = <$fh>) { + if ($a =~ /^# ======/) { + $block = $block + 1; + if ($block == 2) { + last; + } + } + + if ($a =~ /^([0-9A-F]+)\.\.([0-9A-F]+).+\)\s+(.+)$/) { + $start = hex $1; + $end = hex $2; + $comment = $3; + } elsif ($a =~ /^([0-9A-F]+).+\)\s+(.+)$/) { + $start = hex $1; + $end = $start; + $comment = $2; + } else { + next; + } + + if ($oend == 0) { + $ostart = $start; + $oend = $end; + $ocomment = $comment; + } elsif ($oend + 1 == $start) { + # combine + $oend = $end; + } else { + output($fh_out, $ostart, $oend, $ocomment); + $ostart = $start; + $oend = $end; + $ocomment = $comment; + } +} + +if ($oend != 0) { + output($fh_out, $ostart, $oend, $ocomment); +} Modified: trunk/teraterm/teraterm/unicode/get_f_w_a.pl =================================================================== --- trunk/teraterm/teraterm/unicode/get_f_w_a.pl 2022-10-13 14:27:25 UTC (rev 10313) +++ trunk/teraterm/teraterm/unicode/get_f_w_a.pl 2022-10-15 14:38:44 UTC (rev 10314) @@ -1,48 +1,48 @@ -#!/usr/bin/perl -use utf8; - -open(FILE, "EastAsianWidth.txt") || die "Cannot open width file."; -$ostart = -1; -while($a = <FILE>) { - if ($a =~ /^([0-9A-F]+)\.\.([0-9A-F]+);([A-Za-z]+)/) { - $start = hex $1; - $end = hex $2; - $type = $3; - if ($type eq "Na") { - $type = "n"; - } - } - elsif ($a =~ /^([0-9A-F]+);([A-Za-z]+)/) { - $start = hex $1; - $end = hex $1; - $type = $2; - if ($type eq "Na") { - $type = "n"; - } - } else { - next; - } - -# printf("-{ 0x%06x, 0x%06x, $type },\n", $start, $end); - - if ($otype eq $type - #&& $oend+1 == $start # 未定義部を飛ばしてつなげる - ) - { - # 1つ前とつなげる - $oend = $end; - } elsif ($ostart == -1) { - $ostart = $start; - $oend = $end; - $otype = $type; - } else { - if (($otype eq "W") || ($otype eq "F") || ($otype eq "A") || - ($otype eq "N") || ($otype eq "n")) { - printf("{ 0x%06x, 0x%06x, '$otype' },\n", $ostart, $oend); - } - $ostart = $start; - $oend = $end; - $otype = $type; - } -} -printf("{ 0x%06x, 0x%06x, '$type' },\n", $ostart, $oend); +#!/usr/bin/perl +use utf8; + +open(FILE, "EastAsianWidth.txt") || die "Cannot open width file."; +$ostart = -1; +while($a = <FILE>) { + if ($a =~ /^([0-9A-F]+)\.\.([0-9A-F]+);([A-Za-z]+)/) { + $start = hex $1; + $end = hex $2; + $type = $3; + if ($type eq "Na") { + $type = "n"; + } + } + elsif ($a =~ /^([0-9A-F]+);([A-Za-z]+)/) { + $start = hex $1; + $end = hex $1; + $type = $2; + if ($type eq "Na") { + $type = "n"; + } + } else { + next; + } + +# printf("-{ 0x%06x, 0x%06x, $type },\n", $start, $end); + + if ($otype eq $type + #&& $oend+1 == $start # 未定義部を飛ばしてつなげる + ) + { + # 1つ前とつなげる + $oend = $end; + } elsif ($ostart == -1) { + $ostart = $start; + $oend = $end; + $otype = $type; + } else { + if (($otype eq "W") || ($otype eq "F") || ($otype eq "A") || + ($otype eq "N") || ($otype eq "n")) { + printf("{ 0x%06x, 0x%06x, '$otype' },\n", $ostart, $oend); + } + $ostart = $start; + $oend = $end; + $otype = $type; + } +} +printf("{ 0x%06x, 0x%06x, '$type' },\n", $ostart, $oend);