1. 程式人生 > >ini檔案格式

ini檔案格式

ini檔案定義

https://en.wikipedia.org/wiki/INI_file

The INI file format is an informal standard for configuration files for some platforms or software. INI files are simple text files with a basic structure composed of sections, properties, and values.[1]

INI檔案格式是一種非正式的配置檔案標準,對於一些軟體和平臺使用。

INI檔案是簡單的文字檔案,帶有基本的結構,由 section property 和 value組成。

 

In MS-DOS and 16-bit Windows platforms up through Windows ME, the INI file served as the primary mechanism to configure operating system and installed applications features, such as device drivers, fonts, startup launchers, and things that needed to be initialized in booting Windows. INI files were also generally used by applications to store their individual settings.

[2]

Starting with Windows NT, Microsoft favored the use of the registry, and began to steer developers away from using INI files for configuration. All subsequent versions of Windows have used the Windows Registry for system configuration, and applications built on the .NET Framework use special XML

.config files. The APIs still exist in Windows, however, and developers may still use them.

為微軟早期使用的配置偉岸格式,配置作業系統 和 安裝的軟體功能,例如裝置驅動、字型、啟動發射臺,和其他在啟動過程中使用的引數。

後來從NT開始,微軟使用登錄檔,配置作業系統,應用軟體使用xml檔案配置。使用INI越來越少。

 

The name "INI file" comes from the commonly used filename extension .INI, which stands for "initialization". Other common initialization file extensions are .CFG, .conf,[3] and .TXT,[4] especially CONFIG.SYS and 'config.txt' occurrences.

Linux and Unix systems also use a similar file format for system configuration. In addition, platform-agnostic software may use this file format for configuration. It is human-readable and simple to parse, so it is a usable format for configuration files that do not require much greater complexity.

INI檔案來自於經常使用的檔案字尾 .INI, 表示初始化。 Linux也有使用。 其容易閱讀,並且簡單。

 

格式

https://en.wikipedia.org/wiki/INI_file

Keys (properties)

The basic element contained in an INI file is the key or property. Every key has a name and a value, delimited by an equals sign (=). The name appears to the left of the equals sign.

Note: In the Windows implementation the key cannot contain the characters equal sign ( = ) or semi colon ( ; ) as these are reserved characters. The value can contain any character.

name=value
Sections

Keys may (but need not) be grouped into arbitrarily named sections. The section name appears on a line by itself, in square brackets ([ and ]). All keys after the section declaration are associated with that section. There is no explicit "end of section" delimiter; sections end at the next section declaration, or the end of the file. Sections may not be nested.

Note: In the Windows implementation the section cannot contain the character closing bracket ( ] ).

[section]
a=a
b=b
Case insensitivity

Section and property names are not case sensitive in the Windows implementation.[8]

Comments

Semicolons (;) at the beginning of the line indicate a comment. Comment lines are ignored.

; comment text

 

https://www.cnblogs.com/renyuan/p/4111695.html

INI檔案由節、鍵、值組成。 


   [section] 

引數(鍵=值)
   name=value

註解
   註解使用分號表示(;)。在分號後面的文字,直到該行結尾都全部為註解。

NI檔案的格式很簡單,最基本的三個要素是:parameters,sections和comments。

什麼是parameters?

INI所包含的最基本的“元素”就是parameter;每一個parameter都有一個name和一個value,name和value是由等號“=”隔開。name在等號的左邊。

如:

name = value

什麼是sections ?

所有的parameters都是以sections為單位結合在一起的。所有的section名稱都是獨佔一行,並且sections名字都被方括號包圍著([ and ])。在section聲明後的所有parameters都是屬於該section。對於一個section沒有明顯的結束標誌符,一個section的開始就是上一個section的結束,或者是end of the file。Sections一般情況下不能被nested,當然特殊情況下也可以實現sections的巢狀。

section如下所示:

[section]

什麼是comments ?

在INI檔案中註釋語句是以分號“;”開始的。所有的所有的註釋語句不管多長都是獨佔一行直到結束的。在分號和行結束符之間的所有內容都是被忽略的。

註釋例項如下:

;comments text

 

 

NON GNU INI

http://www.nongnu.org/chmspec/latest/INI.html

 

INI files are text files with CRLF line endings. They are divided into uniquely named sections. The beginning each of section is denoted by a line of the following form: "[section type]" where section type is a series of words. Each section type is followed by lines up to the next section that specify data for that section and each different section type may have a different format.

There are two main types of format following the section type: Each line is variable = value[, value]… Each line is a just an EOL terminated string.

 

The following variables are used below in the description of values in the different format descriptions:

bool

Yes|No

decimal number

(0|1|2|3|4|5|6|7| 8|9)…

hex number

0x(0|1|2|3|4|5|6| 7|8|9|a|b|c|d|e| f|A|B|C|D|E|F)…

number

hex number|decimal number

string

Any character (usually alphanumerics plus underscore) repeated up to the terminator (usually EOL, also '=' or '"')

path

Similar to string, but a file with the same name should exist