[Tutor] Trouble in dealing with special characters.

Alan Gauld alan.gauld at yahoo.co.uk
Fri Dec 7 03:30:34 EST 2018


On 07/12/2018 07:58, Sunil Tech wrote:

> I have a trouble with dealing with special characters in Python Below is
> the sentence with a special character(apostrophe) "MOUNTAIN VIEW WOMEN’S
> HEALTH CLINIC" with actually should be "MOUNTAIN VIEW WOMEN'S HEALTH CLINIC
> ".

How do you define "special characters"?
There is nothing special about the apostraphe. It is just as
valid a character as all the other characters.
What makes it special to you?

> Please help, how to identify these kinds of special characters and replace
> them with appropriate ASCII?

What is appropriate ASCII?
ASCII only has 127 characters.
Unicode has thousands of characters.
How do you want to map a unicode character into ASCII?
There are lots of options but we can't tell what you
think is appropriate.

Finally, character handling changed between Python 2 and 3
(where unicode became the default), so the solution will
likely depend on the Python version you are using.
Please tell us which.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list