Formatted outputs for strings.

Format strings are common char*-strings including any number of %-markers. Every marker is replaced by the next function parameter. The data type of the parameter must match the marker.

"%s, %d, %f" expects (in exactly this sequence) the following parameters :
char* oder String int float

The following table shows all supported %-markers.
Marker Typ Description
%d int Write an integer.
%i
%x int Write a hexadecimal number. Using %x the lower case letters a-f are used, %X uses the upper case letters A-F. The output does not contain any additional text like 0x or <0x...>.
%X
%u int Write a natural number (i.e. an unsigned integer)
%f float Write a float with precision 4. %f uses the point as decimal delimiter, while %F uses the system notation. But of course, the variable itself must be written with the point as decimal delimiter!
%F
%c char Write one character
%s char* Write a char* or String. The string must be 0-terminated, otherwise InDesign® may crash!

Please make sure that the data types of the parameters matching the %-markers exactly. Excess markers are transferred directly to the output.

You may customize the output by special flags between the % and the marker letter. All flags are optionally but take care on their order : The fill characters must always be specified before the decimal places.
  Example Description
-   Justify left. The output must be shorter than the given length in this case of course.
#C, with Unicode (C)<255 #* Pad character. Characters in the range of 128-255 are different on Mac and Windows.
[0]int 20 or 020 Length. If the length starts with 0, '0' ist used as pad character anyway.
.int .6 Precision of floats.

Format-Tag Wert Ausgabe
Integers (int)
**%d** 123 **123**
**%10d** 123 **       123**
**%010d** 123 **0000000123**
**%-10d** 123 **123       **
**%-010d** 123 **1230000000**

Please not that pads may change the value of the representation of integers.
**%#=10d** 123 **=======123**
**%-#=10d** 123 **123=======**
Characters (char)
**%c** 'C' **C**
**%10c** 'L' **         L**
**%010c** 'A' **000000000A**
**%-10c** 'R' **R         **
**%-010c** 'A' **A000000000**
**%#=10c** 'A' **=========A**
**%-#=10c** 'A' **A=========**
Floatings (float)
**%f** 3.1415926 **3.1416**

Note the rounding in the last decimal place.
**%F** 3.1415926 **3,1416**

Note the decimal separator.
**%10f** 3.1415926 **    3.1416**
**%010f** 3.1415926 **00003.1416**
**%-10f** 3.1415926 **3.1416    **
**%-010f** 3.1415926 **3.14160000**

Note the rounding in the last digit after the decimal point and the appended pads.
**%#=10f** 3.1415926 **====3.1416**
**%-#=10f** 3.1415926 **3.1416====**
**%.2f** 3.1415926 **3.14**
**%010.2f** 3.1415926 **0000003.14**
**%.12f** 3.1415926 **3.141592502594**

The IEEE standard will be inaccurate from the seventh decimal place.
Strings (char*)
**%s** "Paul" **Paul**
**%s** "P\xE2\x98\x80ul"**P☀ul**
**%10s** "Paul" **      Paul**
**%010s** "Paul" **000000Paul**
**%-10s** "Paul" **Paul      **
**%-010s** "Paul" **Paul000000**
**%#=10s** "Paul" **======Paul**
**%-#=10s** "Paul" **Paul======**

Format-Tag Wert
\" oder "" "
%% %
\t Tabulator
\n Newline
\r Return
\f Formfeed
\a Alarm. (not supported)
\b Backspace
\v Vertical tab
\0 Ascii-0. This is the end of the string!
\\ \
\xXX, X ∈ [0-9a-fA-F] Ascii letter of give code. Please note that characters greater than 127 must be encoded as UTF-8 characters. So an ä is encoded as \xc3\xa4 but not as \x84 (Mac) or \xE4 (Windows).

Since v4.0.5 R1660 there is no limit  for the length of the result. But please take care that the result string of, for instance, sprintf is limited itself.

Since Version 3.2 R2300 the result string is limited to 32 kB. Longer results are cutted automatically and " ...\n" is appended.

In version prior 3.2 R2299 the result is limited to 1000. Longer results may crash InDesign®.

Since
v1.0

Available
priint:comet InDesign® Plug-Ins, comet_pdf

Alphabetic index HTML hierarchy of classes or Java