Skip to content

Instantly share code, notes, and snippets.

@fasiha
Forked from anonymous/gist:40a7472abe264884768f
Last active August 29, 2015 14:06
Show Gist options
  • Save fasiha/e95ad4e43eed08aa89cc to your computer and use it in GitHub Desktop.
Save fasiha/e95ad4e43eed08aa89cc to your computer and use it in GitHub Desktop.
// タンポポの{綿毛}が風にふかれて飛ぶ。
// わたげ
// 植物のくきは上の方へのびる{性質}がある。
// せいしつ
// 手あらいをよくして伝染<せん>病を{防}ぐ。
// ふせ
// 父は{常}に「腹<はら>八分目」を心がけている。
// つね
// 母は{雑用}が多くてこまっているようだ。
// ざつよう
// 古い{布}を使ってぞうきんを作る。
// ぬの
// 一字{一句}を大切にして文章を読む。
// いっく
// 大豆を使って発芽の{条件}を調べる。
// じょうけん
// 友達が{険}しい顔つきになった。
// けわ
// 新校舎が完成して{祝賀}会が行われた。
// しゅくが
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace kanken
{
class Program
{
//argument one is the input file (ques_kd3.bin)
//argument two is the output (my_dumped_text.txt etc)
static void Main(string[] args)
{
var shift_jis_encoding = Encoding.GetEncoding(932);
//offsets (including inital length byte)
//10kyuu yomi - 0x1316bc
// 6kyuu yomi - 0x188F5F
var start_offset = 0x188F5F;
//all the questions and answers
List<String> list = new List<String>();
using (BinaryReader reader = new BinaryReader(new FileStream(args[0], FileMode.Open)))
{
reader.BaseStream.Seek(start_offset, SeekOrigin.Begin);
//don't know the length of a section so it's set to 2000 arbitrarily
var section_length = 2000;
for (int i = 0; i < section_length; i++)
{
//read length
byte[] string_length = new byte[0x10];
reader.Read(string_length, 0, 1);//not sure if the length is only one byte though
var len = (int)string_length[0];
//now we have the length, grab the string
byte[] current_string = new byte[len];
reader.Read(current_string, 0, len);
var decoded_text = shift_jis_encoding.GetString(current_string);
list.Add(decoded_text);
}
}
File.WriteAllLines(args[1],list);
}
}
}
@fasiha
Copy link
Author

fasiha commented Sep 14, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment