Expand description
Plain text file handling with encoding detection and format recognition.
This module provides the Text type for working with plain text files in Total War
PackFiles. It supports multiple encodings and automatically detects file formats based
on extensions to enable syntax highlighting and validation in editors.
§Supported Encodings
- ISO-8859-15: Western European character set (legacy support)
- UTF-8: Modern Unicode encoding (default)
- UTF-8 with BOM: UTF-8 with Byte Order Mark
- UTF-16 LE: UTF-16 Little Endian with BOM
Encoding is automatically detected by examining Byte Order Marks (BOMs) and attempting to decode the data. When encoding, the original encoding is preserved.
§Format Detection
The module automatically detects file formats based on file extensions, enabling appropriate syntax highlighting and validation. Supported formats include Lua scripts, XML configuration, JSON data, shader code, and more.
§Supported File Extensions
The following table lists all file extensions recognized as text files:
| —————————– | ––––– | —————————————–– |
| Extension | Format | Description |
|---|---|---|
.agf | Plain | |
.bat | Bat | Windows batch script. |
.battle_script | Lua | Battle script in Lua. |
.battle_speech_camera | Plain | Camera settings for battle speeches. |
.benchmark | Xml | Benchmark settings. |
.bob | Plain | BoB settings file. |
.cco | Plain | |
.cindyscene | Xml | Cutscene editor data. |
.cindyscenemanager | Xml | Cutscene manager data. |
.code-snippets | Json | VSCode snippet file. |
.code-workspace | Json | VSCode workspace file. |
.css | Css | CSS stylesheet. |
.csv | Plain | Comma-separated values file. |
.environment | Xml | Environment settings. |
.environment_group | Xml | Environment group settings. |
.environment_group.override | Xml | Environment group overrides. |
.fbx | Plain | Autodesk FBX (text format). |
.fx | Cpp | DirectX effect file. |
.fx_fragment | Cpp | DirectX effect fragment. |
.glsl | Cpp | OpenGL shader source. |
.h | Cpp | C/C++ header file. |
.hlsl | Hlsl | High Level Shading Language. |
.htm | Html | HTML document. |
.html | Html | HTML document. |
.inl | Cpp | C++ inline file. |
.json | Json | JSON data file. |
.js | Js | JavaScript file. |
.kfa | Xml | Battle Audio Event file. |
.kfc | Xml | Battle Camera file. |
.kfe | Xml | Battle Effect file. |
.kfe_temp | Xml | Battle Effect (temporary). |
.kfl | Xml | Battle Point Light file. |
.kfl_temp | Xml | Battle Point Light (temporary). |
.kfsl | Xml | Battle Spot Light file. |
.kfp | Xml | Battle Prop file. |
.kfcs | Xml | Battle Composite Scene file. |
.kfcs_temp | Xml | Battle Composite Scene (temporary). |
.ktr | Xml | Battle Tracker file. |
.ktr_temp | Xml | Battle Tracker (temporary). |
.lighting | Xml | Lighting configuration. |
.log | Plain | Log file. |
.lua | Lua | Lua script file. |
.material | Xml | Material definition. |
.md | Markdown | Markdown documentation. |
.model_statistics | Xml | Model statistics data. |
.mvscene | Xml | Movie scene file. |
.py | Python | Python script. |
.sbs | Xml | Substance Designer file. |
.shader | Xml | Shader definition. |
.sql | Sql | SQL query file. |
.tai | Plain | |
.technique | Xml | Rendering technique definition. |
.texture_array | Plain | List of campaign map textures. |
.tsv | Plain | Tab-separated values file. |
.twui | Lua | Total War UI file (Lua format). |
.txt | Plain | Plain text file. |
.xml | Xml | XML file. |
.xml_temp | Xml | XML (temporary). |
.xml.shader | Xml | Shader metadata (XML). |
.xml.material | Xml | Material metadata (XML). |
.xt | Plain | Text file (typo variant). |
.yml | Yaml | YAML configuration file. |
.yaml | Yaml | YAML configuration file. |
Note: .variantmeshdefinition and .wsmodel are also supported but listed separately in the code.
Structs§
- Text
- In-memory representation of a decoded text file.
Enums§
- Encoding
- Character encoding types supported for text files.
- Text
Format - File format types for syntax highlighting and validation.
Constants§
- EXTENSIONS
- List of extensions we recognize as
Textfiles, with their respective known format. - EXTENSION_
VMD - Extension for VMD, or Variant Mesh Definitions.
- EXTENSION_
WSMODEL - Extension for WS Models.