nei

package
v2.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package nei 实现 KISS 游戏共用的 .nei 加密 CSV 表格格式 COM3D2 与 KCES 使用完全相同的容器结构,仅单元格文本的字符编码不同,因此实现放在共用包中,由各游戏包提供自身语义的封装 Package nei implements the encrypted .nei CSV table format shared by KISS games COM3D2 and KCES use an identical container structure and differ only in the character encoding of cell text, so the implementation lives in a shared package and each game package wraps it with its own semantics

Index

Constants

This section is empty.

Variables

View Source
var (
	// Signature 是 .nei 解密后数据的固定签名
	// Signature is the fixed signature of decrypted .nei data
	Signature = []byte{0x77, 0x73, 0x76, 0xFF}

	// Key 是默认加密密钥
	// Key is the default encryption key
	Key = []byte{
		0xAA, 0xC9, 0xD2, 0x35,
		0x22, 0x87, 0x20, 0xF2,
		0x40, 0xC5, 0x61, 0x7C,
		0x01, 0xDF, 0x66, 0x54,
	}
)

Functions

This section is empty.

Types

type Table

type Table struct {
	Rows uint32     `json:"Rows"` // CSV 的行数 / Number of CSV rows
	Cols uint32     `json:"Cols"` // CSV 的列数 / Number of CSV columns
	Data [][]string `json:"Data"` // CSV 的数据 [行][列] / CSV cell data indexed as [row][column]
	// 单元格文本的字符编码,读取时按内容探测,写出时为空等同于 Shift-JIS
	// Character encoding of cell text, detected from content while reading, and an empty value writes as Shift-JIS
	TextEncoding TextEncoding `json:"TextEncoding,omitempty"`
}

Table 表示解密后的 .nei CSV 表格数据 Table represents decrypted .nei CSV table data

func Read

func Read(r io.Reader, key []byte) (*Table, error)

Read 从 r 中读取一个 .nei 文件,并解析为 Table 结构,单元格编码按内容探测 key 传入 nil 则使用默认密钥 Read reads a .nei file from r and parses it into a Table structure, detecting the cell encoding from content Passing nil as key selects the default key

func (*Table) Dump

func (table *Table) Dump(w io.Writer) error

Dump 将 table 写出到 w 中,格式与 .nei 兼容,单元格按 TextEncoding 编码 Dump writes table to w in a format compatible with .nei, encoding cells according to TextEncoding

type TextEncoding

type TextEncoding string

TextEncoding 表示 .nei 单元格文本使用的字符编码 / TextEncoding represents the character encoding used by .nei cell text

const (
	// TextEncodingShiftJIS 是 COM3D2 读取 .nei 时使用的 Shift-JIS(CP932)编码
	// TextEncodingShiftJIS is the Shift-JIS (CP932) encoding COM3D2 uses when reading .nei
	TextEncodingShiftJIS TextEncoding = "Shift-JIS"
	// TextEncodingUTF8 是 KCES 读取 .nei 时使用的 UTF-8 编码
	// TextEncodingUTF8 is the UTF-8 encoding KCES uses when reading .nei
	TextEncodingUTF8 TextEncoding = "UTF-8"
)

func DetectTextEncoding

func DetectTextEncoding(cells [][]byte) TextEncoding

DetectTextEncoding 按单元格字节内容探测 .nei 表格使用的文本编码 COM3D2 与 KCES 的 .nei 共用签名与结构,只能靠内容区分:KCES 写出的日文是合法 UTF-8,而 Shift-JIS 的假名与大多数汉字首字节落在 UTF-8 的非法首字节区 全部单元格都是 ASCII 时两种编码等价,返回 Shift-JIS 以保持既有默认 DetectTextEncoding detects the text encoding of a .nei table from the cell bytes COM3D2 and KCES .nei files share a signature and structure and can only be told apart by content: the Japanese text KCES writes is valid UTF-8, while Shift-JIS kana and most kanji lead bytes fall in UTF-8's invalid lead-byte range The two encodings are equivalent when every cell is ASCII, so Shift-JIS is returned to keep the existing default

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL