Skip to main content

Module text

Module text 

Source
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:

| —————————– | ––––– | —————————————–– |

ExtensionFormatDescription
.agfPlain
.batBatWindows batch script.
.battle_scriptLuaBattle script in Lua.
.battle_speech_cameraPlainCamera settings for battle speeches.
.benchmarkXmlBenchmark settings.
.bobPlainBoB settings file.
.ccoPlain
.cindysceneXmlCutscene editor data.
.cindyscenemanagerXmlCutscene manager data.
.code-snippetsJsonVSCode snippet file.
.code-workspaceJsonVSCode workspace file.
.cssCssCSS stylesheet.
.csvPlainComma-separated values file.
.environmentXmlEnvironment settings.
.environment_groupXmlEnvironment group settings.
.environment_group.overrideXmlEnvironment group overrides.
.fbxPlainAutodesk FBX (text format).
.fxCppDirectX effect file.
.fx_fragmentCppDirectX effect fragment.
.glslCppOpenGL shader source.
.hCppC/C++ header file.
.hlslHlslHigh Level Shading Language.
.htmHtmlHTML document.
.htmlHtmlHTML document.
.inlCppC++ inline file.
.jsonJsonJSON data file.
.jsJsJavaScript file.
.kfaXmlBattle Audio Event file.
.kfcXmlBattle Camera file.
.kfeXmlBattle Effect file.
.kfe_tempXmlBattle Effect (temporary).
.kflXmlBattle Point Light file.
.kfl_tempXmlBattle Point Light (temporary).
.kfslXmlBattle Spot Light file.
.kfpXmlBattle Prop file.
.kfcsXmlBattle Composite Scene file.
.kfcs_tempXmlBattle Composite Scene (temporary).
.ktrXmlBattle Tracker file.
.ktr_tempXmlBattle Tracker (temporary).
.lightingXmlLighting configuration.
.logPlainLog file.
.luaLuaLua script file.
.materialXmlMaterial definition.
.mdMarkdownMarkdown documentation.
.model_statisticsXmlModel statistics data.
.mvsceneXmlMovie scene file.
.pyPythonPython script.
.sbsXmlSubstance Designer file.
.shaderXmlShader definition.
.sqlSqlSQL query file.
.taiPlain
.techniqueXmlRendering technique definition.
.texture_arrayPlainList of campaign map textures.
.tsvPlainTab-separated values file.
.twuiLuaTotal War UI file (Lua format).
.txtPlainPlain text file.
.xmlXmlXML file.
.xml_tempXmlXML (temporary).
.xml.shaderXmlShader metadata (XML).
.xml.materialXmlMaterial metadata (XML).
.xtPlainText file (typo variant).
.ymlYamlYAML configuration file.
.yamlYamlYAML 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.
TextFormat
File format types for syntax highlighting and validation.

Constants§

EXTENSIONS
List of extensions we recognize as Text files, with their respective known format.
EXTENSION_VMD
Extension for VMD, or Variant Mesh Definitions.
EXTENSION_WSMODEL
Extension for WS Models.