轻轻松松背单词II 词库转换器(源代码)

原理很简单,看看就懂:)

Imports System.IO

Imports System.Text

Module BDCWordConverter

    Sub main()

        Dim dir As New DirectoryInfo("D:/bdc/Word/")

        Dim fi As FileInfo() = dir.GetFiles("*.gds")

        For Each f As FileInfo In fi

            Dim fs As New FileStream(f.FullName, FileMode.Open)

            Dim br As New BinaryReader(fs)

            fs.Position = 12

            Dim b01 As Byte() = br.ReadBytes(20)

            ReDim Preserve b01(27)

            br.BaseStream.Position = 50

            Dim b02 As Byte() = br.ReadBytes(8)

            b02.CopyTo(b01, 20)

 

            Console.WriteLine(f.FullName)

            Dim fileName As String = New StringBuilder(Encoding.GetEncoding("GB2312").GetChars(b01)).ToString.TrimEnd(CChar(" "))

 

            Console.WriteLine("Processing {0}", fileName)

            Dim fw As New StreamWriter("D:/bdc word/" & fileName.TrimEnd(Chr(0)) & ".txt")

            Dim startPos As Integer = 290

            Dim offWord As Integer = 30

            Dim offPun As Integer = 30

            Dim offMean As Integer = 40

            Dim offCourse As Integer = 28

            br.BaseStream.Position = 290

 

            Dim Word As String

            Dim Pun As String

            Dim Mean As String

            Do Until br.PeekChar = -1

                Dim b1 As Byte() = br.ReadBytes(offWord)

                Word = New ASCIIEncoding().GetChars(b1)

                Dim b2 As Byte() = br.ReadBytes(offPun)

                Pun = New ASCIIEncoding().GetChars(b2)

                Dim b3 As Byte() = br.ReadBytes(offMean)

                Mean = New StringBuilder(Encoding.GetEncoding("GB2312").GetChars(b3)).ToString

                br.ReadBytes(offCourse)

                fw.WriteLine("""{0}"",""{1}"",""{2}""", Word.TrimEnd(CChar(" ")), Pun.TrimEnd(CChar(" ")), Mean.TrimEnd(CChar(" ")))

            Loop

            fs.Flush()

            fs.Close()

        Next

    End Sub

End Module

 

发布了63 篇原创文章 · 获赞 0 · 访问量 19万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览