12.4 The Foreign Include File
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Foreign Language Interface
        • The Foreign Include File
          • Argument Passing and Control
          • Atoms and functors
          • Input and output
          • Analysing Terms via the Foreign Interface
          • Constructing Terms
          • Unifying data
          • Convenient functions to generate Prolog exceptions
          • Foreign language wrapper support functions
          • Serializing and deserializing Prolog terms
          • BLOBS: Using atoms to store arbitrary binary data
          • Exchanging GMP numbers
          • Calling Prolog from C
          • Discarding Data
          • String buffering
          • Foreign Code and Modules
          • Prolog exceptions in foreign code
          • Catching Signals (Software Interrupts)
          • Miscellaneous
          • Errors and warnings
          • Environment Control from Foreign Code
          • Querying Prolog
          • Registering Foreign Predicates
          • Foreign Code Hooks
          • Storing foreign data
          • Embedding SWI-Prolog in other applications
          • Locale and PL_initialise()
    • Packages

12.4.26 Locale and PL_initialise()

PL_initialise() reads the numeric conventions (decimal point, thousands separator, digit grouping) of the environment's LC_NUMERIC locale for use by locale-sensitive predicates such as format/3 with  :d and  :f directives. See section 4.23. It does so without calling setlocale(), so the embedder's process locale is left untouched and functions such as atof() and printf()("%f") continue to use the decimal point that was in effect before PL_initialise() was called.

PL_initialise() does call setlocale() for LC_CTYPE (to pick up the multibyte encoding used for atoms and streams), LC_TIME and LC_COLLATE. Embedders that require a strict "C" locale for these categories should either arrange the environment before starting the process or reset the desired categories after PL_initialise() returns.