This file is indexed.

/usr/share/doc/racket/reference/encodings.html is in racket-doc 6.7-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>13.1.1&nbsp;Encodings and Locales</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="extras.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">&#9658;</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x"><span style="font-weight: bold">The Racket Reference</span></a></td></tr></table></div><div class="tocviewsublisttop" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1&nbsp;</td><td><a href="model.html" class="tocviewlink" data-pltdoc="x">Language Model</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="notation.html" class="tocviewlink" data-pltdoc="x">Notation for Documentation</a></td></tr><tr><td align="right">3&nbsp;</td><td><a href="syntax.html" class="tocviewlink" data-pltdoc="x">Syntactic Forms</a></td></tr><tr><td align="right">4&nbsp;</td><td><a href="data.html" class="tocviewlink" data-pltdoc="x">Datatypes</a></td></tr><tr><td align="right">5&nbsp;</td><td><a href="structures.html" class="tocviewlink" data-pltdoc="x">Structures</a></td></tr><tr><td align="right">6&nbsp;</td><td><a href="mzlib_class.html" class="tocviewlink" data-pltdoc="x">Classes and Objects</a></td></tr><tr><td align="right">7&nbsp;</td><td><a href="mzlib_unit.html" class="tocviewlink" data-pltdoc="x">Units</a></td></tr><tr><td align="right">8&nbsp;</td><td><a href="contracts.html" class="tocviewlink" data-pltdoc="x">Contracts</a></td></tr><tr><td align="right">9&nbsp;</td><td><a href="match.html" class="tocviewlink" data-pltdoc="x">Pattern Matching</a></td></tr><tr><td align="right">10&nbsp;</td><td><a href="control.html" class="tocviewlink" data-pltdoc="x">Control Flow</a></td></tr><tr><td align="right">11&nbsp;</td><td><a href="concurrency.html" class="tocviewlink" data-pltdoc="x">Concurrency and Parallelism</a></td></tr><tr><td align="right">12&nbsp;</td><td><a href="Macros.html" class="tocviewlink" data-pltdoc="x">Macros</a></td></tr><tr><td align="right">13&nbsp;</td><td><a href="input-and-output.html" class="tocviewselflink" data-pltdoc="x">Input and Output</a></td></tr><tr><td align="right">14&nbsp;</td><td><a href="security.html" class="tocviewlink" data-pltdoc="x">Reflection and Security</a></td></tr><tr><td align="right">15&nbsp;</td><td><a href="os.html" class="tocviewlink" data-pltdoc="x">Operating System</a></td></tr><tr><td align="right">16&nbsp;</td><td><a href="memory.html" class="tocviewlink" data-pltdoc="x">Memory Management</a></td></tr><tr><td align="right">17&nbsp;</td><td><a href="unsafe.html" class="tocviewlink" data-pltdoc="x">Unsafe Operations</a></td></tr><tr><td align="right">18&nbsp;</td><td><a href="running.html" class="tocviewlink" data-pltdoc="x">Running Racket</a></td></tr><tr><td align="right"></td><td><a href="doc-bibliography.html" class="tocviewlink" data-pltdoc="x">Bibliography</a></td></tr><tr><td align="right"></td><td><a href="doc-index.html" class="tocviewlink" data-pltdoc="x">Index</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_1&quot;);">&#9658;</a></td><td>13&nbsp;</td><td><a href="input-and-output.html" class="tocviewlink" data-pltdoc="x">Input and Output</a></td></tr></table><div class="tocviewsublist" style="display: none;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">13.1&nbsp;</td><td><a href="ports.html" class="tocviewselflink" data-pltdoc="x">Ports</a></td></tr><tr><td align="right">13.2&nbsp;</td><td><a href="Byte_and_String_Input.html" class="tocviewlink" data-pltdoc="x">Byte and String Input</a></td></tr><tr><td align="right">13.3&nbsp;</td><td><a href="Byte_and_String_Output.html" class="tocviewlink" data-pltdoc="x">Byte and String Output</a></td></tr><tr><td align="right">13.4&nbsp;</td><td><a href="Reading.html" class="tocviewlink" data-pltdoc="x">Reading</a></td></tr><tr><td align="right">13.5&nbsp;</td><td><a href="Writing.html" class="tocviewlink" data-pltdoc="x">Writing</a></td></tr><tr><td align="right">13.6&nbsp;</td><td><a href="pretty-print.html" class="tocviewlink" data-pltdoc="x">Pretty Printing</a></td></tr><tr><td align="right">13.7&nbsp;</td><td><a href="Reader_Extension.html" class="tocviewlink" data-pltdoc="x">Reader Extension</a></td></tr><tr><td align="right">13.8&nbsp;</td><td><a href="Printer_Extension.html" class="tocviewlink" data-pltdoc="x">Printer Extension</a></td></tr><tr><td align="right">13.9&nbsp;</td><td><a href="serialization.html" class="tocviewlink" data-pltdoc="x">Serialization</a></td></tr><tr><td align="right">13.10&nbsp;</td><td><a href="fasl.html" class="tocviewlink" data-pltdoc="x">Fast-<wbr></wbr>Load Serialization</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_2&quot;);">&#9660;</a></td><td>13.1&nbsp;</td><td><a href="ports.html" class="tocviewlink" data-pltdoc="x">Ports</a></td></tr></table><div class="tocviewsublistbottom" style="display: block;" id="tocview_2"><table cellspacing="0" cellpadding="0"><tr><td align="right">13.1.1&nbsp;</td><td><a href="" class="tocviewselflink" data-pltdoc="x">Encodings and Locales</a></td></tr><tr><td align="right">13.1.2&nbsp;</td><td><a href="port-ops.html" class="tocviewlink" data-pltdoc="x">Managing Ports</a></td></tr><tr><td align="right">13.1.3&nbsp;</td><td><a href="port-buffers.html" class="tocviewlink" data-pltdoc="x">Port Buffers and Positions</a></td></tr><tr><td align="right">13.1.4&nbsp;</td><td><a href="linecol.html" class="tocviewlink" data-pltdoc="x">Counting Positions, Lines, and Columns</a></td></tr><tr><td align="right">13.1.5&nbsp;</td><td><a href="file-ports.html" class="tocviewlink" data-pltdoc="x">File Ports</a></td></tr><tr><td align="right">13.1.6&nbsp;</td><td><a href="stringport.html" class="tocviewlink" data-pltdoc="x">String Ports</a></td></tr><tr><td align="right">13.1.7&nbsp;</td><td><a href="pipeports.html" class="tocviewlink" data-pltdoc="x">Pipes</a></td></tr><tr><td align="right">13.1.8&nbsp;</td><td><a href="portstructs.html" class="tocviewlink" data-pltdoc="x">Structures as Ports</a></td></tr><tr><td align="right">13.1.9&nbsp;</td><td><a href="customport.html" class="tocviewlink" data-pltdoc="x">Custom Ports</a></td></tr><tr><td align="right">13.1.10&nbsp;</td><td><a href="port-lib.html" class="tocviewlink" data-pltdoc="x">More Port Constructors, Procedures, and Events</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><a href="#%28def._%28%28quote._~23~25kernel%29._current-locale%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">current-<wbr></wbr>locale</span></span></a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, &quot;6.7&quot;, &quot;../&quot;);" onfocus="this.style.color=&quot;black&quot;; this.style.textAlign=&quot;left&quot;; if (this.value == &quot;...search manuals...&quot;) this.value=&quot;&quot;;" onblur="if (this.value.match(/^ *$/)) { this.style.color=&quot;#888&quot;; this.style.textAlign=&quot;center&quot;; this.value=&quot;...search manuals...&quot;; }"/></form>&nbsp;&nbsp;<a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;6.7&quot;);">top</a></span><span class="navright">&nbsp;&nbsp;<a href="ports.html" title="backward to &quot;13.1 Ports&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="ports.html" title="up to &quot;13.1 Ports&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="port-ops.html" title="forward to &quot;13.1.2 Managing Ports&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div><h5 x-source-module="(lib &quot;scribblings/reference/reference.scrbl&quot;)" x-source-pkg="racket-doc" x-part-tag="&quot;encodings&quot;">13.1.1<tt>&nbsp;</tt><a name="(part._encodings)"></a>Encodings and Locales</h5><p>When a port is provided to a character-based operation, such as
<span class="RktSym"><a href="Byte_and_String_Input.html#%28def._%28%28quote._~23~25kernel%29._read-char%29%29" class="RktValLink" data-pltdoc="x">read-char</a></span> or <span class="RktSym"><a href="Reading.html#%28def._%28%28quote._~23~25kernel%29._read%29%29" class="RktValLink" data-pltdoc="x">read</a></span>, the port&rsquo;s bytes are read and
interpreted as a UTF-8 encoding of characters. Thus, reading a single
character may require reading multiple bytes, and a procedure like
<span class="RktSym"><a href="Byte_and_String_Input.html#%28def._%28%28quote._~23~25kernel%29._char-ready~3f%29%29" class="RktValLink" data-pltdoc="x">char-ready?</a></span> may need to peek several bytes into the stream to
determine whether a character is available. In the case of a byte
stream that does not correspond to a valid UTF-8 encoding, functions
such as <span class="RktSym"><a href="Byte_and_String_Input.html#%28def._%28%28quote._~23~25kernel%29._read-char%29%29" class="RktValLink" data-pltdoc="x">read-char</a></span> may need to peek one byte ahead in the
stream to discover that the stream is not a valid encoding.</p><p>When an input port produces a sequence of bytes that is not a valid
UTF-8 encoding in a character-reading context, then bytes that
constitute an invalid sequence are converted to the character
<span class="RktVal">#\uFFFD</span>. Specifically, bytes 255 and 254 are always converted
to <span class="RktVal">#\uFFFD</span>, bytes in the range 192 to 253 produce
<span class="RktVal">#\uFFFD</span> when they are not followed by bytes that form a valid
UTF-8 encoding, and bytes in the range 128 to 191 are converted to
<span class="RktVal">#\uFFFD</span> when they are not part of a valid encoding that was
started by a preceding byte in the range 192 to 253. To put it another
way, when reading a sequence of bytes as characters, a minimal set of
bytes are changed to the encoding of <span class="RktVal">#\uFFFD</span> so that the
entire sequence of bytes is a valid UTF-8 encoding.</p><p>See <a href="bytestrings.html" data-pltdoc="x">Byte Strings</a> for procedures that facilitate
conversions using UTF-8 or other encodings. See also
<span class="RktSym"><a href="port-lib.html#%28def._%28%28lib._racket%2Fport..rkt%29._reencode-input-port%29%29" class="RktValLink" data-pltdoc="x">reencode-input-port</a></span> and <span class="RktSym"><a href="port-lib.html#%28def._%28%28lib._racket%2Fport..rkt%29._reencode-output-port%29%29" class="RktValLink" data-pltdoc="x">reencode-output-port</a></span> for
obtaining a UTF-8-based port from one that uses a different encoding
of characters.</p><p>A <a name="(tech._locale)"></a><span style="font-style: italic">locale</span> captures information about a user&rsquo;s
language-specific interpretation of character sequences. In particular,
a locale determines how strings are &ldquo;alphabetized,&rdquo; how a lowercase
character is converted to an uppercase character, and how strings are
compared without regard to case. String operations such as
<span class="RktSym"><a href="strings.html#%28def._%28%28quote._~23~25kernel%29._string-ci~3d~3f%29%29" class="RktValLink" data-pltdoc="x">string-ci=?</a></span> are <span style="font-style: italic">not</span> sensitive to the current locale,
but operations such as <span class="RktSym"><a href="strings.html#%28def._%28%28quote._~23~25kernel%29._string-locale-ci~3d~3f%29%29" class="RktValLink" data-pltdoc="x">string-locale-ci=?</a></span> (see
<a href="strings.html" data-pltdoc="x">Strings</a>) produce results consistent with the current
locale.</p><p>A locale also designates a particular encoding of code-point sequences
into byte sequences. Racket generally ignores this aspect of the
locale, with a few notable exceptions: command-line arguments passed
to Racket as byte strings are converted to character strings using the
locale&rsquo;s encoding; command-line strings passed as byte strings to
other processes (through <span class="RktSym"><a href="subprocess.html#%28def._%28%28quote._~23~25kernel%29._subprocess%29%29" class="RktValLink" data-pltdoc="x">subprocess</a></span>) are converted to byte
strings using the locale&rsquo;s encoding; environment variables are
converted to and from strings using the locale&rsquo;s encoding; filesystem
paths are converted to and from strings (for display purposes) using
the locale&rsquo;s encoding; and, finally, Racket provides functions such as
<span class="RktSym"><a href="bytestrings.html#%28def._%28%28quote._~23~25kernel%29._string-~3ebytes%2Flocale%29%29" class="RktValLink" data-pltdoc="x">string-&gt;bytes/locale</a></span> to specifically invoke a locale-specific
encoding.</p><p>A Unix user selects a locale by setting environment variables, such as
<span class="stt">LC_ALL</span>. On Windows and Mac OS X, the operating system
provides other mechanisms for setting the locale. Within Racket, the
current locale can be changed by setting the <span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._current-locale%29%29" class="RktValLink" data-pltdoc="x">current-locale</a></span>
parameter. The locale name within Racket is a string, and the
available locale names depend on the platform and its configuration,
but the <span class="RktVal">""</span> locale means the current user&rsquo;s default locale;
on Windows and Mac OS X, the encoding for <span class="RktVal">""</span> is always
UTF-8, and locale-sensitive operations use the operating system&rsquo;s
native interface. (In particular, setting the <span class="stt">LC_ALL</span> and
<span class="stt">LC_CTYPE</span> environment variables does not affect the locale
<span class="RktVal">""</span> on Mac OS X. Use <span class="RktSym"><a href="envvars.html#%28def._%28%28lib._racket%2Fprivate%2Fmisc..rkt%29._getenv%29%29" class="RktValLink" data-pltdoc="x">getenv</a></span> and
<span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._current-locale%29%29" class="RktValLink" data-pltdoc="x">current-locale</a></span> to explicitly install the
environment-specified locale, if desired.) Setting the current locale
to <span class="RktVal">#f</span> makes locale-sensitive operations locale-insensitive,
which means using the Unicode mapping for case operations and using
UTF-8 for encoding.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>parameter</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((quote._~23~25kernel)._current-locale))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._current-locale%29%29" class="RktValDef RktValLink" data-pltdoc="x">current-locale</a></span></span><span class="RktPn"></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>&rarr;<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="RktPn">(</span><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._current-locale%29%29" class="RktValDef RktValLink" data-pltdoc="x">current-locale</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">locale</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>&rarr;<span class="hspace">&nbsp;</span><span class="RktSym"><a href="void.html#%28def._%28%28quote._~23~25kernel%29._void~3f%29%29" class="RktValLink" data-pltdoc="x">void?</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">locale</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">A <a href="eval-model.html#%28tech._parameter%29" class="techoutside" data-pltdoc="x"><span class="techinside">parameter</span></a> that determines the current <a href="#%28tech._locale%29" class="techoutside" data-pltdoc="x"><span class="techinside">locale</span></a> for
procedures such as <span class="RktSym"><a href="strings.html#%28def._%28%28quote._~23~25kernel%29._string-locale-ci~3d~3f%29%29" class="RktValLink" data-pltdoc="x">string-locale-ci=?</a></span>.</div></p><p>When locale sensitivity is disabled by setting the parameter to
<span class="RktVal">#f</span>, strings are compared, etc., in a fully portable manner,
which is the same as the standard procedures. Otherwise, strings are
interpreted according to a locale setting (in the sense of the C
library&rsquo;s <span class="stt">setlocale</span>). The <span class="RktVal">""</span> locale is always an alias
for the current machine&rsquo;s default locale, and it is the default.  The
<span class="RktVal">"C"</span> locale is also always available; setting the locale to
<span class="RktVal">"C"</span> is the same as disabling locale sensitivity with
<span class="RktVal">#f</span> only when string operations are restricted to the first
128 characters. Other locale names are platform-specific.</p><p>String or character printing with <span class="RktSym"><a href="Writing.html#%28def._%28%28quote._~23~25kernel%29._write%29%29" class="RktValLink" data-pltdoc="x">write</a></span> is not affected by
the parameter, and neither are symbol case or regular expressions (see
<a href="regexp.html" data-pltdoc="x">Regular Expressions</a>).</p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, &quot;6.7&quot;, &quot;../&quot;);" onfocus="this.style.color=&quot;black&quot;; this.style.textAlign=&quot;left&quot;; if (this.value == &quot;...search manuals...&quot;) this.value=&quot;&quot;;" onblur="if (this.value.match(/^ *$/)) { this.style.color=&quot;#888&quot;; this.style.textAlign=&quot;center&quot;; this.value=&quot;...search manuals...&quot;; }"/></form>&nbsp;&nbsp;<a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;6.7&quot;);">top</a></span><span class="navright">&nbsp;&nbsp;<a href="ports.html" title="backward to &quot;13.1 Ports&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="ports.html" title="up to &quot;13.1 Ports&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="port-ops.html" title="forward to &quot;13.1.2 Managing Ports&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div></body></html>