SDF/fr

From Lazarus wiki
Revision as of 13:46, 14 June 2017 by E-ric (talk | contribs) (Created page with "{{SDF}} {{Infobox databases/fr}} '''SDF''' est format de fichier en texte délimité utilisé dans Delphi (et ensuite par Free Pascal) qui est très proche de CSV s...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

English (en) français (fr)

Portail de la base de données

Références:

Tutoriels/articles pratiques :

Bases de données

Advantage - MySQL - MSSQL - Postgres - Interbase - Firebird - Oracle - ODBC - Paradox - SQLite - dBASE - MS Access - Zeos

SDF est format de fichier en texte délimité utilisé dans Delphi (et ensuite par Free Pascal) qui est très proche de CSV sans être identique. (.sdf est aussi l'extension des fichiers de données de Microsoft SQL Server, il n'est donc pas conseillé d'employer cette extension pour vos fichiers.

Format SDF

A summary of the SDF format as used in TStringList, as paraphrased/synthesized from various versions of Delphi help (e.g. DelimitedText, StrictDelimiter)

  • If you get DelimitedText, strings that include spaces, Delimiter (e.g. ,) or QuoteChar must be enclosed in QuoteChars (" by default) aka quoted. (In practice - read Delphi does this -, however, with StrictDelimiter on, e.g. spaced text is not quoted)
  • In addition, a QuoteChar in a string must be repeated.
  • When setting DelimitedText, strings must be separated by Delimiter characters or spaces.
  • Strings may be enclosed in QuoteChars.
  • QuoteChars in the string must be repeated to distinguish them from the QuoteChars enclosing the string.
  • Delimiters that are not contained within QuoteChar marks must be handled as delimiters
  • If StrictDelimiter is false, spaces that are not contained within QuoteChar marks 'must be handled as delimiters.
  • Two Delimiters in a row indicate an empty string.

Exemple de sortie

Example SDF output (tested in Delphi and FPC after applying the patch for issue 19610):

Light bulb  Remarque: FPC versions below 2.6.0 do not generate SDF according to the specification

This series of strings in a stringlist (note: numbers in front indicate the field for clarity, they are not part of the data):

0normal_string
1includes;delimiter
2includes space
3includes"quote
4includes "quote and space
5tab	character
6"single_starting_quote
7multi
line.
8   SpacesInFront
9SpacesAtTheEnd

gets output as this with StrictDelimiter true (and ; as delimiter):

normal_string;"includes;delimiter";includes space;"includes""quote";"includes ""quote and space";tab	character;"""single_starting_quote";multi
line.;   SpacesInFront;SpacesAtTheEnd  

... and output as this with StrictDelimiter false:

normal_string;"includes;delimiter";"includes space";"includes""quote";"includes ""quote and space";"tab	character";"""single_starting_quote";"multi
line.";"   SpacesInFront";"SpacesAtTheEnd  "

Voir aussi