ini file configuration feature
ini file is a file extension and data format for configuration and setup files for software applications. ini is abbreviated as Initialize values very popularly used by the Windows Operating System.
ini files look like properties files with comments, headers
Key and values
ini file contains a group of items, each item contains keys and values separated by the equal symbol
key=value
- the key is a valid identifier that will not contain
=
or;
symbols. - The value is the valid identifier of any string
- Key can be String, number, or Boolean values.
Sections
sections are grouped with similar key and value pairs under one name enclosed in a square bracket, these are called sections or headers.
[Section or Header]
key1=value1
key2=value2
- Section or Headers contain multiple keys and value pairs in a separate line
- There can be multiple sections
- section is optional
Comments
Comments are ignored by the compiler. ;
symbol at the beginning of a line tells it is a comment and is ignored by the processor.
; comment text
Options with the same key and multiple different values
Options are identified using the same key with different values. Each option is declared in a separate line as follows.
option1=male
option1=female
How to write multiline values for a given key?
You can write a key with a single line value, However, you can write a multi-line value using triple quotes
with prefixes and suffixes of multiple values.
[feature]
key = """
This is a
multi-line
value.
"""
Another way to write a multi-line value, is the second statement is prefixed with spaces
[example]
key = Statement one.
Statement Two.
Ini Array values for a given key
The key can contain multiple values as an array.
Defined a key prefixed with []
, and assign the value. The same key is used for multiple values assignment.
[Weekend]
days[] = Saturday
days[] = Sunday
Special and Escape characters for a values
You can not define keys with special and escape characters, but values can contain them.
Special characters
[character]
special = !@#$%^&*()_+
Escape characters
[filesystem]
programfiles = c://programfiles
temppath = c:/temp
Important rules:
- section and key names are cases insensitive
- section and key can not be spaces
- section, key, and values are encoded in ISO 8859-1
- Binary data can be encoded in ASCII or ISO 8859-1
- if the same multiple section names are there, the last section considers
- Nested sections are not allowed.
Supported Features
Items | Status |
---|---|
Single Comments | ✅ |
In line Comments | ✅ |
| Multi line Comments | ✅ | | Key-value separator | ✅ | | Sections | ✅ | | Section Whitespace | ✅ | | Speacial Characters Value | ✅ | | Multi-line strings Values | ✅ | | Array concatenation | ✅ | | Nested Sections | ✅ | | Escape Characaters | ✅ |