千家信息网

.net词库转换器怎么实现

发表于:2024-11-24 作者:千家信息网编辑
千家信息网最后更新 2024年11月24日,这篇文章主要介绍".net词库转换器怎么实现",在日常操作中,相信很多人在.net词库转换器怎么实现问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答".net词库转换器怎么
千家信息网最后更新 2024年11月24日.net词库转换器怎么实现

这篇文章主要介绍".net词库转换器怎么实现",在日常操作中,相信很多人在.net词库转换器怎么实现问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答".net词库转换器怎么实现"的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

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

Imports System.IOImports System.TextModule BDCWordConverterSub main()Dim dir As New DirectoryInfo("D:bdcWord")Dim fi As FileInfo() = dir.GetFiles("*.gds")For Each f As FileInfo In fiDim fs As New FileStream(f.FullName, FileMode.Open)Dim br As New BinaryReader(fs)fs.Position = 12Dim b01 As Byte() = br.ReadBytes(20)ReDim Preserve b01(27)br.BaseStream.Position = 50Dim 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 = 290Dim offWord As Integer = 30Dim offPun As Integer = 30Dim offMean As Integer = 40Dim offCourse As Integer = 28br.BaseStream.Position = 290Dim Word As StringDim Pun As StringDim Mean As StringDo Until br.PeekChar = -1Dim 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)).ToStringbr.ReadBytes(offCourse)fw.WriteLine("""{0}"",""{1}"",""{2}""", Word.TrimEnd(CChar(" ")), Pun.TrimEnd(CChar(" ")), Mean.TrimEnd(CChar(" ")))Loopfs.Flush()fs.Close()NextEnd SubEnd Module

到此,关于".net词库转换器怎么实现"的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!

0