G3027_こまかなバグの修正①
2025年4月16日
3:49
G3027_pc_goma_note_bag_report_1
翻訳の追加機能を作る過程で不都合が
Com_txt_tbl_red2()関数
// テキストファイル読込み (可変文字配列)
public static string[] Com_txt_tbl_red2(
string prm_fil_path,
int prm_tbl_no,
string prm_type, // "A" ANSI "U" UTF-8
out int prm_tbl_max)
{
Encoding enc;
string txt_buf;
int rec_cnt = 0;
string[] fld_tbl = new string[100];
prm_tbl_max = 0;
if (prm_type == "A") enc = Encoding.GetEncoding("Shift_JIS");
else enc = Encoding.GetEncoding("UTF-8");
if (System.IO.File.Exists(prm_fil_path) == false)
{
string[] empty = new string[2];
return empty;
}
// レコード件数を調べます
using (StreamReader red = new StreamReader(prm_fil_path, enc))
{
while (red.EndOfStream == false)
{
txt_buf = red.ReadLine();
++rec_cnt;
}
}
prm_tbl_max = rec_cnt;
string[] ans_tbl = new string[prm_tbl_max];
rec_cnt = 0;
using (StreamReader red = new StreamReader(prm_fil_path, enc))
{
while (red.EndOfStream == false)
{
txt_buf = red.ReadLine();
if(txt_buf != "")
{
fld_tbl = txt_buf.Split(',');
if (fld_tbl.Length < prm_tbl_no + 1) ans_tbl[rec_cnt] = "";
else ans_tbl[rec_cnt] = fld_tbl[prm_tbl_no];
}
else
{
ans_tbl[rec_cnt] = "";
}
++rec_cnt;
}
}
return ans_tbl;
}
キーワード、スペルを使った翻訳機能
翻訳実行