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 7409381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:04:31+00:00 2026-05-29T06:04:31+00:00

The data stored in unicode (in database) has to be retrieved and convert into

  • 0

The data stored in unicode (in database) has to be retrieved and convert into a different form.

The following snippet

def convert(content):
    content = content.replace("ஜௌ", "n\[s");
    return content;

mydatabase = "database.db"
connection = sqlite3.connect(mydatabase)
cursor = connection.cursor()
query = ''' select unicode_data from table1'''
cursor.execute(query)
for row in cursor.fetchone():
    print convert(row)

yields the following error message in convert method.

exceptions.UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe0 in
position 0: ordinal not in range(128)

If the database content is “ஜௌஜௌஜௌ”, the output should be “n\[sn\[sn\[s”

The documentation suggests to use ignore or replace to avoid the error, when creating the unicode string.

when the iteration is changed as follows:

for row in cursor.fetchone():
    print convert(unicode(row, errors='replace'))

it returns

exceptions.TypeError: decoding Unicode is not supported

which informs that row is already a unicode.

Any light on this to make it work is highly appreciated. Thanks in advance.

  • 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-05-29T06:04:31+00:00Added an answer on May 29, 2026 at 6:04 am
    content = content.replace("ஜௌ", "n\[s");
    

    Suggest you mean:

    content = content.replace(u'ஜௌ', ur'n\[s');
    

    or for safety where the encoding of your file is uncertain:

    content = content.replace(u'\u0B9C\u0BCC', ur'n\[s');
    

    The content you have is already Unicode, so you should do Unicode string replacements on it. "ஜௌ" without the u is a string of bytes that represents those characters in some encoding dependent on your source file charset. (Byte strings work smoothly together with Unicode strings only in the most unambiguous cases, which is for ASCII characters.)

    (The r-string means not having to worry about including bare backslashes.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I noticed something while uploading some unicode data to the database. When the content
If the amount of data stored within a given field of a database is
I have data stored as below in an MS Access database: Date User 20090101
Are there techniques for comparing the same data stored in different schemas? The situation
I have a database which contains picture data stored as a binary blob. The
I'm looking for help to convert an ASCII MD5 hashed password into a Unicode
I need to convert a non-unicode SQL Server 2005 database to a unicode based
I have the data stored in a format different from the display format. I've
I am using this code to read data from Oracle Database. That data stored
I have some data stored as ArrayList . And when I want to backup

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.