Documentation
¶
Index ¶
- Constants
- func BuildRangeTree(list []*MdictRecordBlockInfoListItem, root *RecordBlockRangeTreeNode)
- type Dictionary
- type MDictKeywordEntry
- type MDictKeywordIndex
- type MDictKeywordIndexRecordBlock
- type Mdict
- func (mdict *Mdict) BuildIndex() error
- func (mdict *Mdict) CreationDate() string
- func (mdict *Mdict) Description() string
- func (mdict *Mdict) Digest() string
- func (mdict *Mdict) Encoding() int
- func (mdict *Mdict) GeneratedByEngineVersion() string
- func (mdict *Mdict) GetKeyWordEntries() ([]*MDictKeywordEntry, error)
- func (mdict *Mdict) GetKeyWordEntriesSize() int64
- func (mdict *Mdict) IsMDD() bool
- func (mdict *Mdict) IsRecordEncrypted() bool
- func (mdict *Mdict) IsUTF16() bool
- func (mdict *Mdict) KeywordEntryToIndex(item *MDictKeywordEntry) (*MDictKeywordIndex, error)
- func (mdict *Mdict) LocateByKeywordEntry(entry *MDictKeywordEntry) ([]byte, error)
- func (mdict *Mdict) LocateByKeywordIndex(index *MDictKeywordIndex) ([]byte, error)
- func (mdict *Mdict) Lookup(word string) ([]byte, error)
- func (mdict *Mdict) Name() string
- func (mdict *Mdict) StyleSheet() string
- func (mdict *Mdict) Title() string
- func (mdict *Mdict) Version() string
- type MdictAccessor
- type MdictBase
- type MdictRecordBlockInfoListItem
- type MdictType
- type RecordBlockRangeTreeNode
Constants ¶
const ( MdictTypeMdd MdictType = 1 MdictTypeMdx MdictType = 2 EncryptNoEnc = 0 EncryptRecordEnc = 1 EncryptKeyInfoEnc = 2 NumfmtBe8bytesq = 0 NumfmtBe4bytesi = 1 EncodingUtf8 = 0 EncodingUtf16 = 1 EncodingBig5 = 2 ENCODING_GBK = 3 ENCODING_GB2312 = 4 EncodingGb18030 = 5 )
Variables ¶
This section is empty.
Functions ¶
func BuildRangeTree ¶
func BuildRangeTree(list []*MdictRecordBlockInfoListItem, root *RecordBlockRangeTreeNode)
Types ¶
type Dictionary ¶
type Dictionary struct {
GeneratedByEngineVersion string
RequiredEngineVersion string
Encrypted string
// NOTE: the real text encoding lives in the "Encoding" attribute; the
// upstream code mapped this field to "IsUTF16" by mistake, which silently
// misdetected every non-UTF16 dictionary (e.g. GBK) as UTF-8.
Encoding string
IsUTF16 string
Format string
Stripkey string
CreationDate string
Compact string
Compat string
KeyCaseSensitive string
Description string
Title string
DataSourceFormat string
StyleSheet string
Left2Right string
RegisterBy string
UUID string
ContentType string
DefaultSortingLocale string
}
Dictionary holds the attributes parsed from the MDict header.
v1/v2 headers use the <Dictionary ...> root tag; v3 headers use <ZDB ...>. Rather than fighting encoding/xml's strict root-tag matching, we parse the attributes with a regex (mirroring the reference Python reader's _parse_header) so both root tags work uniformly.
type MDictKeywordEntry ¶
type MDictKeywordIndex ¶
type MDictKeywordIndex struct {
//encoding int
//encryptType int
KeywordEntry MDictKeywordEntry
RecordBlock MDictKeywordIndexRecordBlock
}
type Mdict ¶
type Mdict struct {
*MdictBase
// contains filtered or unexported fields
}
func (*Mdict) CreationDate ¶
func (*Mdict) Description ¶
func (*Mdict) Encoding ¶
Encoding returns the dictionary's text encoding as one of the Encoding* / ENCODING_* constants. For non-UTF16 MDX dictionaries LocateByKeywordEntry returns record bytes still in this native encoding (UTF16 is decoded to UTF-8 internally), so callers must transcode accordingly.
func (*Mdict) GeneratedByEngineVersion ¶
func (*Mdict) GetKeyWordEntries ¶
func (mdict *Mdict) GetKeyWordEntries() ([]*MDictKeywordEntry, error)
func (*Mdict) GetKeyWordEntriesSize ¶
func (*Mdict) IsRecordEncrypted ¶
func (*Mdict) KeywordEntryToIndex ¶
func (mdict *Mdict) KeywordEntryToIndex(item *MDictKeywordEntry) (*MDictKeywordIndex, error)
func (*Mdict) LocateByKeywordEntry ¶
func (mdict *Mdict) LocateByKeywordEntry(entry *MDictKeywordEntry) ([]byte, error)
func (*Mdict) LocateByKeywordIndex ¶
func (mdict *Mdict) LocateByKeywordIndex(index *MDictKeywordIndex) ([]byte, error)
func (*Mdict) StyleSheet ¶
StyleSheet returns the raw StyleSheet header attribute (groups of three lines: number, begin, end), empty when the dictionary defines none.
type MdictAccessor ¶
type MdictAccessor struct {
Filepath string `json:"filepath"`
IsRecordEncrypted bool `json:"is_record_encrypted"`
IsMDD bool `json:"is_mdd"`
IsUTF16 bool `json:"is_utf_16"`
}
func NewAccessor ¶
func NewAccessor(mdict *Mdict) *MdictAccessor
func NewAccessorFromJson ¶
func NewAccessorFromJson(data []byte) (*MdictAccessor, error)
func (*MdictAccessor) RetrieveDefByIndex ¶
func (mdi *MdictAccessor) RetrieveDefByIndex(index *MDictKeywordIndex) ([]byte, error)
func (*MdictAccessor) Serialize ¶
func (mdi *MdictAccessor) Serialize() ([]byte, error)
type MdictRecordBlockInfoListItem ¶
type MdictRecordBlockInfoListItem struct {
// contains filtered or unexported fields
}
func QueryRangeData ¶
func QueryRangeData(root *RecordBlockRangeTreeNode, queryRange int64) *MdictRecordBlockInfoListItem
type RecordBlockRangeTreeNode ¶
type RecordBlockRangeTreeNode struct {
// contains filtered or unexported fields
}