Revision: 10316 https://osdn.net/projects/ttssh2/scm/svn/commits/10316 Author: zmatsuo Date: 2022-10-15 23:39:04 +0900 (Sat, 15 Oct 2022) Log Message: ----------- 絵文字とEastAsianWidthテーブル作成スクリプトを修正 - テーブルに元ファイルのバージョン情報(日付)を出力するようにした - ファイルに出力するとき perl で直接ファイルを生成するようにした - リダイレクトを使用しない - 環境が違っても同一のファイルが生成できるようにするため - unicode_emoji.tbl には Unicode が含まれるため BOM 付きで出力する - VS で警告が出るため - warning C4819: ファイルは、現在のコード ページ (932) で表示できない文字を含んでいます。 データの損失を防ぐために、ファイルを Unicode 形式で保存してください。 - ドキュメントを更新 - 元ファイルのURLを修正 - Unicode 15.0 Modified Paths: -------------- trunk/teraterm/teraterm/unicode/get_asianwidth_table.md trunk/teraterm/teraterm/unicode/get_asianwidth_table.pl trunk/teraterm/teraterm/unicode/get_emoji_table.md trunk/teraterm/teraterm/unicode/get_emoji_table.pl -------------- next part -------------- Modified: trunk/teraterm/teraterm/unicode/get_asianwidth_table.md =================================================================== --- trunk/teraterm/teraterm/unicode/get_asianwidth_table.md 2022-10-15 14:38:54 UTC (rev 10315) +++ trunk/teraterm/teraterm/unicode/get_asianwidth_table.md 2022-10-15 14:39:04 UTC (rev 10316) @@ -2,20 +2,22 @@ # unicodeの全角半角 - unicode.orgにある East Asian Width に基づいて決める + - https://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt +- `unicode_asian_width.tbl` を生成する -# テーブルの作り方 - -- あらかじめ EastAsianWidth.txt をダウンロードしておく -- 次のように実行 - - `perl get_asianwidth_table.pl > unicode_asian_width.tbl` - ## East Asian Width について https://ja.wikipedia.org/wiki/%E6%9D%B1%E3%82%A2%E3%82%B8%E3%82%A2%E3%81%AE%E6%96%87%E5%AD%97%E5%B9%85 -## original data +# テーブルの作り方 -http://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt +- あらかじめ EastAsianWidth.txt をダウンロードしておく + - `wget https://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt` +- 次のように実行 + - `perl get_asianwidth_table.pl` - EastAsianWidth-12.1.0.txt - Date: 2019-03-31, 22:01:58 GMT [KW, LI] +実行例 +``` +wget https://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt +perl get_asianwidth_table.pl +``` Modified: trunk/teraterm/teraterm/unicode/get_asianwidth_table.pl =================================================================== --- trunk/teraterm/teraterm/unicode/get_asianwidth_table.pl 2022-10-15 14:38:54 UTC (rev 10315) +++ trunk/teraterm/teraterm/unicode/get_asianwidth_table.pl 2022-10-15 14:39:04 UTC (rev 10316) @@ -1,9 +1,29 @@ #!/usr/bin/perl +use strict; +use warnings; use utf8; -open(FILE, "EastAsianWidth.txt") || die "Cannot open width file."; -$ostart = -1; -while($a = <FILE>) { +my $src_file = "EastAsianWidth.txt"; +my $fname_out = "unicode_asian_width.tbl"; + +open(FILE, $src_file) || die "Cannot open $src_file."; +open(my $fh_out, ">:crlf:utf8", $fname_out) || die "Cannot open $fname_out."; +print $fh_out "// this file was generated by get_asianwidth_table.pl\n"; + +my $v = <FILE>; +chop($v); +print $fh_out "// $v\n"; +$v = <FILE>; +chop($v); +print $fh_out "// $v\n"; + +my $ostart = -1; +my $otype = ""; +my $oend = 0; +my $type; +while(my $a = <FILE>) { + my $start; + my $end; if ($a =~ /^([0-9A-F]+)\.\.([0-9A-F]+);([A-Za-z]+)/) { $start = hex $1; $end = hex $2; @@ -38,7 +58,7 @@ } 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); + printf($fh_out "{ 0x%06x, 0x%06x, '$otype' },\n", $ostart, $oend); } $ostart = $start; $oend = $end; @@ -45,4 +65,4 @@ $otype = $type; } } -printf("{ 0x%06x, 0x%06x, '$type' },\n", $ostart, $oend); +printf($fh_out "{ 0x%06x, 0x%06x, '$type' },\n", $ostart, $oend); Modified: trunk/teraterm/teraterm/unicode/get_emoji_table.md =================================================================== --- trunk/teraterm/teraterm/unicode/get_emoji_table.md 2022-10-15 14:38:54 UTC (rev 10315) +++ trunk/teraterm/teraterm/unicode/get_emoji_table.md 2022-10-15 14:39:04 UTC (rev 10316) @@ -2,25 +2,24 @@ # unicodeの絵文字 - unicode.orgにある 絵文字データ に基づいて絵文字のコード - https://unicode.org/Public/emoji/12.1/emoji-data.txt + - https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt - 絵文字を判定するテーブルを作成する + - unicode_emoji.tbl -# テーブルの作り方 - -- あらかじめ emoji-data.txt をダウンロードしておく - - `wget https://unicode.org/Public/emoji/12.1/emoji-data.txt` -- 次のように実行 - - `perl get_emoji_table.pl` - # etc - CJK環境では絵文字は全角 - 非CJKでは0x1f000未満の絵文字は半角、それ以外は全角 -## original data +# テーブルの作り方 -https://unicode.org/Public/emoji/12.1/emoji-data.txt +- あらかじめ emoji-data.txt をダウンロードしておく + - `wget https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt` +- 次のように実行 + - `perl get_emoji_table.pl` - # emoji-data.txt - # Date: 2019-01-15, 12:10:05 GMT - # © 2019 Unicode®, Inc. +実行例 +``` +wget https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt +perl get_emoji_table.pl +``` Modified: trunk/teraterm/teraterm/unicode/get_emoji_table.pl =================================================================== --- trunk/teraterm/teraterm/unicode/get_emoji_table.pl 2022-10-15 14:38:54 UTC (rev 10315) +++ trunk/teraterm/teraterm/unicode/get_emoji_table.pl 2022-10-15 14:39:04 UTC (rev 10316) @@ -22,8 +22,15 @@ 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"); +print $fh_out "// this file was generated by get_emoji_table.pl\n"; +my $v = <$fh>; +chop($v); +print $fh_out "// $v\n"; +$v = <$fh>; +chop($v); +print $fh_out "// $v\n"; + my $block = 0; my $start; my $end;