Processing strings

Version :
09.11.2021, 08:27 Uhr

Processing strings

static int replace_all(
  char* str,
  char* search,
  char* replace)

Replace all occurences of a string with another string. The function also operates where the replacement string is a part of mulitple of the searched string. The searched sting may not be empty.

Name Type Default Description
str char* - A replace will be made in this string
search char* - Search for this string. The search string may not be empty.
replace char* - Replace with this string. This string may be empty.


priint:comet InDesign® Plug-Ins, comet_pdf

static int ireplace_all(
  char* str,
  char* key,
  int value)

Replace all occurences of a string with a number. This command is frequently used to update placeholder definitions in tagged text from the database and to replace the text placeholders <ID>, <ID2>, ... there with their current values. The search string may not be empty.

Name Type Default Description
str char* - A replace will be made in this string
search char* - Search for this string. The search string may not be empty.
value int - Replace with this number.


priint:comet InDesign® Plug-Ins, comet_pdf

static int unix_to_win(char* str)

Replace all unix line separators with Windows line separators. Windows line separators consist of two characters, Unix line separators have only one (which is indeed enough). The string then will be made longer by the replacement. You should bear this in mind and reserve sufficient memory.

Name Type Default Description
str char* - String to be processed.


priint:comet InDesign® Plug-Ins, comet_pdf

static int xpress_to_tagged(char* tt)

Convert XPress marked text into tagged text. The tagged text is not completely InDesign® compatible. It contains further tags for the definition of placeholders in texts and for frames.

Name Type Default Description
str char* - String to be processed.


priint:comet InDesign® Plug-Ins, comet_pdf

static char* replace_typografics(char* str)

Replace typografic quotas

Name Type Default Description
Return char*   reference to str
str char* - valid string

#include "internal/text.h"
#include "internal/types.h"
int main () { String cstr = string::alloc (); char str[500];
strcpy (str, textmodel::gettext (cstr));
showmessage ("1 : %s", str); text::replace_typografics (str); showmessage ("2 : %s", str);
return 0; }

Typografic quotas can replaced automatically using the keyword kExportPlainNoTypografics.

#include "internal/types.h"
#include "internal/text.h"
int main () { String cstr = string::alloc (); char str[500];
strcpy (str, textmodel::gettext (cstr,   0, kEnd,   kExportPlainNoTypografics));
showmessage ("1 : %s", str);
return 0; }

Get the same result as in example 1 without using replace_typografics. This exampe only works on Mac!

#include "internal/types.h"
int main () { String cstr = string::alloc (); char str[500];
strcpy (str, textmodel::gettext (cstr));
showmessage ("1 : %s", str); if (system::os () == kMacOS) { text::replace_all (str, "\xe2", "'"); text::replace_all (str, "\xd4", "'"); text::replace_all (str, "\xe3", "\""); text::replace_all (str, "\xd2", "\""); } showmessage ("2 : %s", str);
return 0; }

Version 1.3.4 (P/R 100)

priint:comet InDesign® Plug-Ins, comet_pdf

frame::gettext, table::get_text

static char* fortune(
  char* result,
  char* dbname,
  int seed = -1)

Return a fortune cookie

Name Type Default Description
Return char*   result
result char* - allocated result string
dbname char* - name of the db-file or folder containing db files (relative to Comet PlugIn directory or XML path).
seed int -1 random seed


priint:comet InDesign® Plug-Ins, comet_pdf

static char* find_styled_font(
  char* fontfamily,
  char* fontface,
  int italic,
  int weight,
  int stretch,
  int* found = 0)

Find a font face of given properties in a font family. URL[See here for more information about font famiies, font face and the fontDB.]{../InDesign/Plugins/comet_pdf.html#fontstyle}

Name Type Default Description
Return char*   Font face with given properties.

Not every font has font styles for any combination of font size, width, and style. The found font does not necessarily have to fulfill all parameters. But it is the best possible approximation. Siehe hier für weitere Informationen.

The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. Learn more about functions returning r/o char* values.

fontfamily char* or String - Name of font family
fontface char* or String - Name of font face. Only used if weight > 900 or stretch > 4.
italic int - Font style

0 : Normal
1 : Italic
weight int - Font weight

100, 200, ..., 900 see here

> 900 : I know the style name and search for the associated Italic / Normal font. fontface must not be empty in this case!
stretch int - Font stretch

-4, -3, ..., 4 : ssee here

> 4 : I know the style name and search for the associated Italic / Normal font. fontface must not be empty in this case!
found int* 0 Return value: Face found or not?

0 : Ignore

v4.1 R23232, 30. Mai 2018. Do not use this function in prior releases!

priint:comet InDesign® Plug-Ins, comet_pdf

fontDB, system::fontdb_count, fontdb_get_fontname, fontdb_by_index, fontdb_by_name, fontdb_mark_missing

This class has no child classes.

Author
Paul Seidel
Version
09.11.2021, 08:27 Uhr
Since
Plugin Version 1.0.10

Alphabetic index HTML hierarchy of classes or Java