utf-8

UnicodeDecodeError: 'utf-8' when debugging Python files in PyCharm Community

UnicodeDecodeError: 'utf-8' when debugging Python files in PyCharm Community Question: Current conclusion: The encoding of the converted file is utf-8->utf-8 big->ansi -> utf-8. Reopen the file after each conversion. After observing for a period of time, there is no such error. When I use PyCharm to debug .py files, the same file sometimes has UnicodeDecodeError, …

Total answers: 5

Editing UTF-8 text file on Windows

Editing UTF-8 text file on Windows Question: I’m trying to manipulate a text file with song names. I want to clean up the data, by changing all the spaces and tabs into +. This is the code: input = open(‘music.txt’, ‘r’) out = open("out.txt", "w") for line in input: new_line = line.replace(" ", "+") new_line2 …

Total answers: 1

Convert "x" escaped string into readable string in python

Convert "x" escaped string into readable string in python Question: Is there a way to convert a x escaped string like "\xe8\xaa\x9e\xe8\xa8\x80" into readable form: "語言"? >>> a = "\xe8\xaa\x9e\xe8\xa8\x80" >>> print(a) xe8xaax9exe8xa8x80 I am aware that there is a similar question here, but it seems the solution is only for latin characters. How can …

Total answers: 4

How to read Turkish chars from txt file in Python?

How to read Turkish chars from txt file in Python? Question: I am trying to read user credentials from the text file. In the password, there is ‘ü’ character. When I read from txt. It prints ‘l’ character. UTF8 does not work for Turkish characters. How can I read? def get_username_password(): dosya = open("D:\user.txt","r",encoding="utf8",errors=’ignore’) line …

Total answers: 2

Python: pandas dataframe: Remove "  " BOM character

Python: pandas dataframe: Remove "  " BOM character Question: I used Scrapy on a Linux machine to crawl some websites and saved in a CSV. When I retrieve the dataset and view on a Windows machine, I saw these characters . Here is what I do to re-encode them to UTF-8-SIG: import pandas as …

Total answers: 2

Python 3 : Converting UTF-8 unicode Hindi Literal to Unicode

Python 3 : Converting UTF-8 unicode Hindi Literal to Unicode Question: I have a string of UTF-8 literals ‘xe0xa4xb9xe0xa5x80 xe0xa4xacxe0xa5x8bxe0xa4xb2’ which covnverts to ही बोल in Hindi. I am unable convert string a to bytes a = ‘xe0xa4xb9xe0xa5x80 xe0xa4xacxe0xa5x8bxe0xa4xb2′ #convert a to bytes #also tried a = bytes(a,’utf-8’) a = a.encode(‘utf-8′) s = str(a,’utf-8’) The …

Total answers: 3

Converting a list of tuples containing utf8 data to devanagari text

Converting a list of tuples containing utf8 data to devanagari text Question: I have a list of tuples which contains Unicode text. I’m trying to display/convert it in Devanagari. g=[] g=[(u’u0915u0947u0932u094du092fu094b ‘, u’u0938u0917u0933u094du092fu093eu0902u0924 u091au0921 u096au096b u0927u093eu0902u0935u0921u094du092fu094b ‘), (u’u0936u093fu0916u0930 u0927u0935u0928u093eu0928 ‘, u’u0938u0917u0933u094du092fu093eu0902u0924 u091au0921 u096au096b u0927u093eu0902u0935u0921u094du092fu094b ‘)] [(u’u0938u0928u0930u093eu092fu091du0930u094du0938 u0939u0948u0926u0930u093eu092cu093eu0926 u092eu0941u0902u092cu092f u0907u0902u0921u093fu092fu0928u094du0938u093eu0915 ‘, u’u092au0902u0917u0921u093eu0928 u090fu0915u0947 u0935u093fu0915u0947u091fu0940u0902u0928u0940 ‘), (u’u092au0902u0917u0921u093eu0928 …

Total answers: 1

Cannot convert all elements of csv file to python objects

Cannot convert all elements of csv file to python objects Question: I’m trying to convert all CSV elements to python objects using following python script, but not all characters in CSV file are in UTF-8 and I’ve to convert all those characters to readable format i.e. UTF-8. How can I achieve this? I’ve tried converting …

Total answers: 1

Python prints wrong encoding from MySQL database

Python prints wrong encoding from MySQL database Question: I’m having issues with my Python when calling data from my MySQL database. The database is set as UTF-8 and is containing, special letters such as ‘Æ’ and ‘Ø’. This is the code i use to call the Usernames from my Table # -*- coding: UTF-8 -*- …

Total answers: 1

\x to x with python

\x to x with python Question: I have a string like this: ‘\xac\x85’ and I want to encode these string like this another: ‘xacx85’ I tried a lot of things like encode tu utf-8, replace \x, etc. But when I print the result it always is with \x. Any idea? Asked By: XBoss || Source …

Total answers: 2