mirror of
https://github.com/evennia/evennia.git
synced 2026-03-19 06:16:31 +01:00
275 lines
No EOL
8.7 KiB
HTML
275 lines
No EOL
8.7 KiB
HTML
|
||
|
||
<!DOCTYPE html>
|
||
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||
<head>
|
||
<meta charset="utf-8">
|
||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
||
<title>Text Encodings — Evennia 1.0-dev documentation</title>
|
||
|
||
|
||
|
||
|
||
<link rel="shortcut icon" href="_static/favicon.ico"/>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
|
||
|
||
|
||
|
||
|
||
|
||
<link rel="index" title="Index"
|
||
href="genindex.html"/>
|
||
<link rel="search" title="Search" href="search.html"/>
|
||
<link rel="top" title="Evennia 1.0-dev documentation" href="index.html"/>
|
||
|
||
|
||
<script src="_static/js/modernizr.min.js"></script>
|
||
|
||
</head>
|
||
|
||
<body class="wy-body-for-nav" role="document">
|
||
|
||
|
||
<div class="wy-grid-for-nav">
|
||
|
||
|
||
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||
<div class="wy-side-scroll">
|
||
<div class="wy-side-nav-search">
|
||
|
||
|
||
|
||
<a href="index.html" class="icon icon-home"> Evennia
|
||
|
||
|
||
|
||
</a>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<div role="search">
|
||
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
|
||
<input type="text" name="q" placeholder="Search docs" />
|
||
<input type="hidden" name="check_keywords" value="yes" />
|
||
<input type="hidden" name="area" value="default" />
|
||
</form>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
|
||
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||
|
||
|
||
|
||
<!-- Local TOC -->
|
||
<div class="local-toc"><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>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
|
||
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||
|
||
|
||
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||
|
||
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||
<a href="index.html">Evennia</a>
|
||
|
||
</nav>
|
||
|
||
|
||
|
||
<div class="wy-nav-content">
|
||
<div class="rst-content">
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<div role="navigation" aria-label="breadcrumbs navigation">
|
||
|
||
<ul class="wy-breadcrumbs">
|
||
|
||
<li><a href="index.html">Docs</a> »</li>
|
||
|
||
<li>Text Encodings</li>
|
||
|
||
|
||
<li class="wy-breadcrumbs-aside">
|
||
|
||
|
||
<a href="_sources/Text-Encodings.md.txt" rel="nofollow"> View page source</a>
|
||
|
||
|
||
</li>
|
||
|
||
</ul>
|
||
|
||
|
||
<hr/>
|
||
</div>
|
||
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
||
<div itemprop="articleBody">
|
||
|
||
<div class="section" id="text-encodings">
|
||
<h1>Text Encodings<a class="headerlink" href="#text-encodings" title="Permalink to this headline">¶</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>
|
||
<div class="section" id="how-to-customize-encodings">
|
||
<h2>How to customize encodings<a class="headerlink" href="#how-to-customize-encodings" title="Permalink to this headline">¶</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="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="http://en.wikipedia.org/wiki/Text_encodings">here</a> for more help.</p>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
<footer>
|
||
|
||
|
||
<hr/>
|
||
|
||
<div role="contentinfo">
|
||
<p>
|
||
© Copyright 2020, The Evennia developer community.
|
||
|
||
</p>
|
||
</div>
|
||
Built with <a href="http://sphinx-doc.org/">Sphinx</a> and ❤️ using a custom <a href="https://github.com/LinxiFan/Sphinx-theme">theme</a> based on <a href="https://readthedocs.org">Read the Docs</a>.
|
||
|
||
</footer>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
</section>
|
||
|
||
</div>
|
||
|
||
|
||
|
||
|
||
|
||
<script type="text/javascript">
|
||
var DOCUMENTATION_OPTIONS = {
|
||
URL_ROOT:'./',
|
||
VERSION:'1.0-dev',
|
||
COLLAPSE_INDEX:false,
|
||
FILE_SUFFIX:'.html',
|
||
HAS_SOURCE: true,
|
||
SOURCELINK_SUFFIX: '.txt'
|
||
};
|
||
</script>
|
||
<script type="text/javascript" src="_static/jquery.js"></script>
|
||
<script type="text/javascript" src="_static/underscore.js"></script>
|
||
<script type="text/javascript" src="_static/doctools.js"></script>
|
||
<script type="text/javascript" src="_static/language_data.js"></script>
|
||
|
||
|
||
|
||
|
||
|
||
<script type="text/javascript" src="_static/js/theme.js"></script>
|
||
|
||
|
||
|
||
|
||
<script type="text/javascript">
|
||
jQuery(function () {
|
||
SphinxRtdTheme.StickyNav.enable();
|
||
});
|
||
</script>
|
||
|
||
|
||
</body>
|
||
</html> |