Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8557501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:35:15+00:00 2026-06-11T15:35:15+00:00

I am trying to reverse Hebrew string in Python: line = ‘אבגד’ reversed =

  • 0

I am trying to reverse Hebrew string in Python:

line = 'אבגד'
reversed = line[::-1]
print reversed

but I get:

UnicodeDecodeError: 'ascii' codec can't decode byte 0x93 in position 0: ordinal not in range(128)

Care to explain what I’m doing wrong?

EDIT:

I’m also trying to save the string into a file using:

w1 = open('~/fileName', 'w')
w1.write(reverseLine)

but now I get:

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

Any ideas how to fix that, too?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:35:16+00:00Added an answer on June 11, 2026 at 3:35 pm

    Adding u in front of the hebrew string works for me:

    In [1]: line = u'אבגד'
    
    In [2]: reversed = line[::-1]
    
    In [2]: print reversed
    דגבא
    

    To your second question, you can use:

    import codecs
    
    w1 = codecs.open("~/fileName", "r", "utf-8")
    w1.write(reversed)
    

    To write unicode string to file fileName.

    Alternatively, without using codecs, you will need to encode reversed string with utf-8 when writing to file:

    with open('~/fileName', 'w') as f:
        f.write(reversed.encode('utf-8'))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to reverse words in an array of string variables, but split doesn't
I'm trying to reverse a string and using the below code but the resultant
Trying to reverse a string but getting error in Aggregate function private string Reverse(string
I was trying to reverse a number in PL/SQL. It's working fine, but when
I'm trying to reverse engineer how facebook handles their notifications, where when you get
I am learning C and I'm trying to reverse each string in an array
I'm trying to basically reverse this algorithm so that I get the time for
I am trying to find a way to reverse a string, I've seen alternatives
I am trying to reverse a C style string using the following simple program.
I am trying to reverse a character string in C Here is what I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.