mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
227 lines
No EOL
11 KiB
HTML
227 lines
No EOL
11 KiB
HTML
<!DOCTYPE html>
|
||
|
||
<html lang="en" data-content_root="../">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
|
||
|
||
<title>Text Encodings — Evennia latest documentation</title>
|
||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=d75fae25" />
|
||
<link rel="stylesheet" type="text/css" href="../_static/nature.css?v=279e0f84" />
|
||
<link rel="stylesheet" type="text/css" href="../_static/custom.css?v=e4a91a55" />
|
||
<script src="../_static/documentation_options.js?v=c6e86fd7"></script>
|
||
<script src="../_static/doctools.js?v=9bcbadda"></script>
|
||
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
|
||
<link rel="icon" href="../_static/favicon.ico"/>
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="next" title="Character connection styles" href="Connection-Styles.html" />
|
||
<link rel="prev" title="Internationalization" href="Internationalization.html" />
|
||
</head><body>
|
||
<div class="related" role="navigation" aria-label="Related">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
accesskey="I">index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="Connection-Styles.html" title="Character connection styles"
|
||
accesskey="N">next</a> |</li>
|
||
<li class="right" >
|
||
<a href="Internationalization.html" title="Internationalization"
|
||
accesskey="P">previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="Concepts-Overview.html" accesskey="U">Core Concepts</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">Text Encodings</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
<div class="documentwrapper">
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section class="tex2jax_ignore mathjax_ignore" id="text-encodings">
|
||
<h1>Text Encodings<a class="headerlink" href="#text-encodings" title="Link to this heading">¶</a></h1>
|
||
<p>Evennia is a text-based game server. This makes it important to understand how
|
||
it actually deals with data in the form of text.</p>
|
||
<p>Text <em>byte encodings</em> describe how a string of text is actually stored in the
|
||
computer - that is, the particular sequence of bytes used to represent the
|
||
letters of your particular alphabet. A common encoding used in English-speaking
|
||
languages is the <em>ASCII</em> encoding. This describes the letters in the English
|
||
alphabet (Aa-Zz) as well as a bunch of special characters. For describing other
|
||
character sets (such as that of other languages with other letters than
|
||
English), sets with names such as <em>Latin-1</em>, <em>ISO-8859-3</em> and <em>ARMSCII-8</em>
|
||
are used. There are hundreds of different byte encodings in use around the
|
||
world.</p>
|
||
<p>A string of letters in a byte encoding is represented with the <code class="docutils literal notranslate"><span class="pre">bytes</span></code> type.
|
||
In contrast to the byte encoding is the <em>unicode representation</em>. In Python
|
||
this is the <code class="docutils literal notranslate"><span class="pre">str</span></code> type. The unicode is an internationally agreed-upon table
|
||
describing essentially all available letters you could ever want to print.
|
||
Everything from English to Chinese alphabets and all in between. So what
|
||
Evennia (as well as Python and Django) does is to store everything in Unicode
|
||
internally, but then converts the data to one of the encodings whenever
|
||
outputting data to the user.</p>
|
||
<p>An easy memory aid is that <code class="docutils literal notranslate"><span class="pre">bytes</span></code> are what are sent over the network wire. At
|
||
all other times, <code class="docutils literal notranslate"><span class="pre">str</span></code> (unicode) is used. This means that we must convert
|
||
between the two at the points where we send/receive network data.</p>
|
||
<p>The problem is that when receiving a string of bytes over the network it’s
|
||
impossible for Evennia to guess which encoding was used - it’s just a bunch of
|
||
bytes! Evennia must know the encoding in order to convert back and from the
|
||
correct unicode representation.</p>
|
||
<section id="how-to-customize-encodings">
|
||
<h2>How to customize encodings<a class="headerlink" href="#how-to-customize-encodings" title="Link to this heading">¶</a></h2>
|
||
<p>As long as you stick to the standard ASCII character set (which means the
|
||
normal English characters, basically) you should not have to worry much
|
||
about this section.</p>
|
||
<p>If you want to build your game in another language however, or expect your
|
||
users to want to use special characters not in ASCII, you need to consider
|
||
which encodings you want to support.</p>
|
||
<p>As mentioned, there are many, many byte-encodings used around the world. It
|
||
should be clear at this point that Evennia can’t guess but has to assume or
|
||
somehow be told which encoding you want to use to communicate with the server.
|
||
Basically the encoding used by your client must be the same encoding used by
|
||
the server. This can be customized in two complementary ways.</p>
|
||
<ol class="arabic simple">
|
||
<li><p>Point users to the default <code class="docutils literal notranslate"><span class="pre">@encoding</span></code> command or the <code class="docutils literal notranslate"><span class="pre">@options</span></code> command.
|
||
This allows them to themselves set which encoding they (and their client of
|
||
choice) uses. Whereas data will remain stored as unicode strings internally in
|
||
Evennia, all data received from and sent to this particular player will be
|
||
converted to the given format before transmitting.</p></li>
|
||
<li><p>As a back-up, in case the user-set encoding translation is erroneous or
|
||
fails in some other way, Evennia will fall back to trying with the names
|
||
defined in the settings variable <code class="docutils literal notranslate"><span class="pre">ENCODINGS</span></code>. This is a list of encoding
|
||
names Evennia will try, in order, before giving up and giving an encoding
|
||
error message.</p></li>
|
||
</ol>
|
||
<p>Note that having to try several different encodings every input/output adds
|
||
unneccesary overhead. Try to guess the most common encodings you players will
|
||
use and make sure these are tried first. The International <em>UTF-8</em> encoding is
|
||
what Evennia assumes by default (and also what Python/Django use normally). See
|
||
the Wikipedia article <a class="reference external" href="https://en.wikipedia.org/wiki/Text_encodings">here</a> for more help.</p>
|
||
</section>
|
||
</section>
|
||
|
||
|
||
<div class="clearer"></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sphinxsidebar" role="navigation" aria-label="Main">
|
||
<div class="sphinxsidebarwrapper">
|
||
<p class="logo"><a href="../index.html">
|
||
<img class="logo" src="../_static/evennia_logo.png" alt="Logo of Evennia"/>
|
||
</a></p>
|
||
<search id="searchbox" style="display: none" role="search">
|
||
<h3 id="searchlabel">Quick search</h3>
|
||
<div class="searchformwrapper">
|
||
<form class="search" action="../search.html" method="get">
|
||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||
<input type="submit" value="Go" />
|
||
</form>
|
||
</div>
|
||
</search>
|
||
<script>document.getElementById('searchbox').style.display = "block"</script>
|
||
<h3><a href="../index.html">Table of Contents</a></h3>
|
||
<ul>
|
||
<li><a class="reference internal" href="#">Text Encodings</a><ul>
|
||
<li><a class="reference internal" href="#how-to-customize-encodings">How to customize encodings</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<div>
|
||
<h4>Previous topic</h4>
|
||
<p class="topless"><a href="Internationalization.html"
|
||
title="previous chapter">Internationalization</a></p>
|
||
</div>
|
||
<div>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="Connection-Styles.html"
|
||
title="next chapter">Character connection styles</a></p>
|
||
</div>
|
||
<div role="note" aria-label="source link">
|
||
<!--h3>This Page</h3-->
|
||
<ul class="this-page-menu">
|
||
<li><a href="../_sources/Concepts/Text-Encodings.md.txt"
|
||
rel="nofollow">Show Page Source</a></li>
|
||
</ul>
|
||
</div><h3>Links</h3>
|
||
<ul>
|
||
<li><a href="https://www.evennia.com/docs/latest/index.html">Documentation Top</a> </li>
|
||
<li><a href="https://www.evennia.com">Evennia Home</a> </li>
|
||
<li><a href="https://github.com/evennia/evennia">Github</a> </li>
|
||
<li><a href="http://games.evennia.com">Game Index</a> </li>
|
||
<li>
|
||
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
|
||
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
|
||
<a href="https://evennia.blogspot.com/">Blog</a>
|
||
</li>
|
||
</ul>
|
||
<h3>Doc Versions</h3>
|
||
<ul>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/latest/index.html">latest (main branch)</a>
|
||
</li>
|
||
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/5.x/index.html">v5.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/4.x/index.html">v4.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/3.x/index.html">v3.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/2.x/index.html">v2.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/1.x/index.html">v1.0.0 branch (outdated)</a>
|
||
</li>
|
||
|
||
<li>
|
||
<a href="https://www.evennia.com/docs/0.x/index.html">v0.9.5 branch (outdated)</a>
|
||
</li>
|
||
|
||
</ul>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="clearer"></div>
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="Related">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
>index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="Connection-Styles.html" title="Character connection styles"
|
||
>next</a> |</li>
|
||
<li class="right" >
|
||
<a href="Internationalization.html" title="Internationalization"
|
||
>previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="Concepts-Overview.html" >Core Concepts</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">Text Encodings</a></li>
|
||
</ul>
|
||
</div>
|
||
<div class="footer" role="contentinfo">
|
||
© Copyright 2024, The Evennia developer community.
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.
|
||
</div>
|
||
</body>
|
||
</html> |