Macro/投稿/71
をテンプレートにして作成
Land.to
[
ホーム
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
* PerlScirpt へのパディング処理を行う [#hf776c5f]
-ページ: [[Macro/投稿]]
-作者: [[miau]]
-カテゴリー: pls
-投稿日: 2005-11-07 (月) 00:50:16
** メッセージ [#k9f64578]
#code(perl){{
use strict;
use warnings;
use encoding 'cp932';
binmode(STDERR, ':raw :encoding(cp932)');
use Encode;
# パディングの設定
my $pad_char = "."; # 2 文字目以降の文字
my $pad_columns = 80; # 一行毎の文字数
# 改行コードの判別
my @retcodes = ("\r\n", "\r", "\n");
my $retcode = $retcodes[GetLineCode()];
# テキスト全体を取得
SelectAll();
my $seltext = GetSelectedString(0);
# バイト数取得
use bytes;
my $bytecount = length($seltext);
no bytes;
# 文字数の取得
my $seltext = decode('cp932', $seltext);
my $wordcount = length($seltext);
# 選択解除&ドキュメント末尾に移動
Right();
# 必要ぶん、適当な文字を挿入
my $count = $bytecount - $wordcount; # 挿入が必要な文字数
my $instext = $retcode; # 挿入に使用するバッファ。と...
while ($count > 0) {
$instext .= '#' . $pad_char x ($pad_columns - 1) . $retc...
$count -= $pad_columns;
}
$instext = encode('cp932', $instext); # 挿入前に CP932 に...
InsText($instext);
#...........................................................
#...........................................................
}}
----
#comment
終了行:
* PerlScirpt へのパディング処理を行う [#hf776c5f]
-ページ: [[Macro/投稿]]
-作者: [[miau]]
-カテゴリー: pls
-投稿日: 2005-11-07 (月) 00:50:16
** メッセージ [#k9f64578]
#code(perl){{
use strict;
use warnings;
use encoding 'cp932';
binmode(STDERR, ':raw :encoding(cp932)');
use Encode;
# パディングの設定
my $pad_char = "."; # 2 文字目以降の文字
my $pad_columns = 80; # 一行毎の文字数
# 改行コードの判別
my @retcodes = ("\r\n", "\r", "\n");
my $retcode = $retcodes[GetLineCode()];
# テキスト全体を取得
SelectAll();
my $seltext = GetSelectedString(0);
# バイト数取得
use bytes;
my $bytecount = length($seltext);
no bytes;
# 文字数の取得
my $seltext = decode('cp932', $seltext);
my $wordcount = length($seltext);
# 選択解除&ドキュメント末尾に移動
Right();
# 必要ぶん、適当な文字を挿入
my $count = $bytecount - $wordcount; # 挿入が必要な文字数
my $instext = $retcode; # 挿入に使用するバッファ。と...
while ($count > 0) {
$instext .= '#' . $pad_char x ($pad_columns - 1) . $retc...
$count -= $pad_columns;
}
$instext = encode('cp932', $instext); # 挿入前に CP932 に...
InsText($instext);
#...........................................................
#...........................................................
}}
----
#comment
ページ名: