How to Reverse Hebrew String in Python?
<p>I'm trying to reverse Hebrew string in Python:</p>

<pre><code>line = 'אבגד'
reversed = line[::-1]
print reversed
</code></pre>

<p>but I get: </p>

<pre><code>UnicodeDecodeError: 'ascii' codec can't decode byte 0x93 in position 0: ordinal not in range(128)
</code></pre>

<p>Care to explain what I'm doing wrong? </p>

<p>EDIT: The answers are great, thanks! 
I'm also trying to save the string into a file using:</p>

<pre><code>w1 = open('~/fileName', 'w')
w1.write(reverseLine)
</code></pre>

<p>but now I get:</p>

<pre><code>return codecs.charmap_encode(input,errors,encoding_table)
UnicodeEncodeError: 'charmap' codec can't encode characters in position 1-3: character    maps to &lt;undefined&gt;
</code></pre>

<p>Any ideas how to fix that, too?</p>

<p>EDIT: Found the solution, see my answer below. In short I used </p>

<pre><code>codecs.open('~/fileName', 'w', encoding='utf-8') 
</code></pre>

<p>instead of </p>

<pre><code>open('~/fileName', 'w')
</code></pre>
