PageRenderTime 921ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/_docs/locales.md

https://gitlab.com/unofficial-mirrors/reproducible-website
Markdown | 93 lines | 74 code | 19 blank | 0 comment | 0 complexity | fa97c584983df7137206d094471fb21f MD5 | raw file
  1. ---
  2. title: Locales
  3. layout: docs
  4. permalink: /docs/locales/
  5. ---
  6. The locale of the build system might affect the build products. While
  7. it is important that developers have access to error messages in the
  8. language of their choice, tools which output is influenced by the
  9. current locale can make locale a source of reproducibility issues.
  10. There are many aspects regarding locales (see [GNU libc locale(1)
  11. manpage](https://manpages.debian.org/locale)). The ones that follow are the
  12. most important ones to consider in the context of reproducible builds.
  13. Time format
  14. -----------
  15. Several common time formatting functions will have output depending
  16. on the current locale. On a POSIX system the formatting will depend on
  17. the `LC_CTIME` environment variable, which can be overridden by
  18. `LC_ALL`.
  19. For build systems, it's thus best to use `LC_ALL` directly:
  20. <div class="correct">
  21. {% highlight sh %}
  22. $ LC_ALL=C date -u -d '2015-10-21'
  23. Wed Oct 21 00:00:00 UTC 2015
  24. {% endhighlight %}
  25. </div>
  26. The system [timezone]({{ "/docs/timezones/" | prepend: site.baseurl }})
  27. and `TZ` environment variable will also affect the output of time
  28. formatting functions.
  29. Collation order
  30. ---------------
  31. Common sorting functions are affected by the `LC_COLLATE` environment
  32. variable, which can be overridden by `LC_ALL`. Some locales can
  33. be quite surprising.
  34. This typically shows when using `sort`. The `fr_FR` locale will sort
  35. independently of the character case:
  36. <div class="wrong">
  37. {% highlight sh %}
  38. $ echo B a c | tr ' ' '\n' | LC_ALL=fr_FR.UTF-8 sort
  39. a
  40. B
  41. c
  42. {% endhighlight %}
  43. </div>
  44. The `C` locale will sort according to the byte values and is always
  45. available:
  46. <div class="correct">
  47. {% highlight sh %}
  48. $ echo B a c | tr ' ' '\n' | LC_ALL=C sort
  49. B
  50. a
  51. c
  52. {% endhighlight %}
  53. </div>
  54. Default character encoding
  55. --------------------------
  56. The default system character encoding will affect both the input and
  57. output of many tools. It is defined using the `LC_CTYPE` environment
  58. variable, and can also be overridden using `LC_ALL`.
  59. Here's an example when using `lynx` to convert HTML documentation into
  60. text:
  61. <div class="wrong">
  62. {% highlight sh %}
  63. LC_ALL=fr_FR lynx -dump -width 72 docs.html | file -
  64. /dev/stdin: ISO-8859 text
  65. {% endhighlight %}
  66. </div>
  67. The `C.UTF-8` pseudo-locale can always be used to get the default strings with
  68. UTF-8 output:
  69. <div class="correct">
  70. {% highlight sh %}
  71. LC_ALL=C.UTF-8 lynx -dump -width 72 docs.html | file -
  72. /dev/stdin: UTF-8 Unicode text
  73. {% endhighlight %}
  74. </div>