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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:28:02+00:00 2026-05-13T05:28:02+00:00

I have a feature of my program where the user can upload a csv

  • 0

I have a feature of my program where the user can upload a csv file, which my program goes through and uses as input. I have one user complaining about a problem where his input is throwing up an error. The error is caused by there being an illegal character that is encoded wrong. The characters is below:

�

Sometimes it appears as a diamond with a “?” in the middle, sometimes it appears as a double diamond with “?” in the middle, sometimes it appears as “\xa0”, and sometimes it appears as “\xa0\xa0”.

In my program if I do:

print str_with_weird_char

The string will show up in my terminal with the diamond “?” in place of the weird character. If I copy+paste that string into ipython, it will exit with this message:

In [1]: g="blah��blah"
WARNING: 
********
You or a %run:ed script called sys.stdin.close() or sys.stdout.close()!
Exiting IPython!

notice how the diamond “?” is double now. For some reason copy+paste makes it double…

In the django traceback page, it looks like this:

UnicodeDecodeError at /chris/import.html
('ascii', 'blah \xa0 BLAH', 14, 15, 'ordinal not in range(128)')

The thing that messes me up is that I can’t do anything with this string without it throwing an exception. I tried unicode(), I tried str(), I tried .encode(), I tried .encode(“utf-8”), no matter what it throws up an error.

What can I do it get this thing to be a working string?

  • 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-13T05:28:03+00:00Added an answer on May 13, 2026 at 5:28 am

    You can pass, “ignore” to skip invalid characters in .encode/.decode
    like "ILLEGAL".decode("utf8","ignore")

    >>> "ILLEGA\xa0L".decode("utf8")
    ...
    UnicodeDecodeError: 'utf8' codec can't decode byte 0xa0 in position 6: unexpected code byte
    
    >>> "ILLEGA\xa0L".decode("utf8","ignore")
    u'ILLEGAL'
    >>>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am adding a feature to my program in which the user will have
I have a feature which allows the user to create projects and view it
I want to have this feature in my C# program: When the user do
I have a clock feature in a VB.NET program that displays the time including
I develop a Python-based drawing program, Whyteboard . I have tools that the user
i have a input tag which is non editable, but some times i need
I have a program that stores it's information in an XML file. This file
My Goal I am attempting to make a Java program in which a user
Does Eclipse have a feature that lets you search a project to find all
i have a Sharepoint feature that essentially extends Lists with a new feature, using

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.