I only code in English but I have to deal with python unicode all the time. Sometimes its hard to remove unicode character from and dict. How can I change python default character encoding to ASCII???
-
Which problems specifically are you having? And are you that your problem is the choice of default encoding, not that encoding discipline (the difference between text and bytes) is enforced at all?user395760– user3957602014-01-20 17:26:11 +00:00Commented Jan 20, 2014 at 17:26
-
The A in ASCII, stands for American, so could be a you'll get one or two problems that will cost you a few £s, doing that...Tony Hopkinson– Tony Hopkinson2014-01-20 17:29:56 +00:00Commented Jan 20, 2014 at 17:29
-
1Learn to deal with Unicode. It's not going away, and there are non-ASCII characters--punctuation, mostly, but the occasional accented vowel as well--that are can appear in English text.chepner– chepner2014-01-20 17:33:24 +00:00Commented Jan 20, 2014 at 17:33
-
1Why don't you tell us about a specific problem your are having, and we can help you deal with that specific problem. Don't try to crack this nut with a sledgehammer, you are going about it the wrong way.Martijn Pieters– Martijn Pieters2014-01-20 17:37:18 +00:00Commented Jan 20, 2014 at 17:37
-
My problem was to pass unserialized mogodb query result with unicode to template in django because I could not use serializers ,json,simplejson and cjson.But this helped [stackoverflow.com/questions/455580/…Praveen Singh Yadav– Praveen Singh Yadav2014-01-20 19:59:57 +00:00Commented Jan 20, 2014 at 19:59
Add a comment
|
1 Answer
That would be the wrong thing to do. As in very wrong. To start with, it would only give you an UnicodeDecodeError instead of removing the characters. Learn proper encoding and decoding to/from unicode so that you can filter out tthe values using rules like errors="ignore"
You can't just ignore the characters taht are part of your data, just because you 'dislike" then. It is text, and in an itnerconected World, text is not composed of only 26 glyphs.
I'd suggest you get started by reading this document: http://www.joelonsoftware.com/articles/Unicode.html