encoding

Russian symbols in Python output corrupted (ENCODING)

我的梦境 提交于 2021-02-07 19:40:19
问题 I parsed a HTML document and have Russian text in it. When I'm trying to print it in Python, I get this: ÐлÑбниÑнÑй новогодний пÑÐ½Ñ I tried to decode it and I get ISO-8859-1 encoding. I'm trying to decode it like that: print drink_name.decode('iso8859-1') But I get an error. How can I print this text, or encode it in Unicode? 回答1: You have a Mojibake; UTF-8 bytes decoded as Latin-1 or CP1251 in this case. You can repair it by reversing the process: >>> print u'ÐлÑбнÐ

RGB buffer to JPEG buffer, what is wrong here?

[亡魂溺海] 提交于 2021-02-07 19:23:43
问题 I need an easy way to convert an buffer containing RGB data into a jpeg. I already tried using libjpeg, but I simply cannot get it to work right. For example, while saving the buffer as a Bitmap produces this: Using libjpeg to encode the same image in memory produces this: And saving the image directly to a file just aborts without giving a warning, error or anything. I certainly need something that works! This is what I am doing void OnKeyPress(unsigned char key, int x, int y) { if (key !=

RGB buffer to JPEG buffer, what is wrong here?

我们两清 提交于 2021-02-07 19:23:22
问题 I need an easy way to convert an buffer containing RGB data into a jpeg. I already tried using libjpeg, but I simply cannot get it to work right. For example, while saving the buffer as a Bitmap produces this: Using libjpeg to encode the same image in memory produces this: And saving the image directly to a file just aborts without giving a warning, error or anything. I certainly need something that works! This is what I am doing void OnKeyPress(unsigned char key, int x, int y) { if (key !=

Special characters appearing as question marks

懵懂的女人 提交于 2021-02-07 19:15:05
问题 Using the Python programming language, I'm having trouble outputting characters such as å, ä and ö. The following code gives me a question mark (?) as output, not an å: #coding: iso-8859-1 input = "å" print input The following code lets you input random text. The for-loop goes through each character of the input, adds them to the string variable a and then outputs the resulting string. This code works correctly; you can input å, ä and ö and the output will still be correct. For example, "år"

Special characters appearing as question marks

天大地大妈咪最大 提交于 2021-02-07 19:09:44
问题 Using the Python programming language, I'm having trouble outputting characters such as å, ä and ö. The following code gives me a question mark (?) as output, not an å: #coding: iso-8859-1 input = "å" print input The following code lets you input random text. The for-loop goes through each character of the input, adds them to the string variable a and then outputs the resulting string. This code works correctly; you can input å, ä and ö and the output will still be correct. For example, "år"

Python - Reading and writing csv files with utf-8 encoding

我的未来我决定 提交于 2021-02-07 13:37:16
问题 I'm trying to read a csv file the its header contains foreign characters and I'm having a lot of problems with this. first of all, I'm reading the file with a simple csv.reader filename = 'C:\\Users\\yuval\\Desktop\\בית ספר\\עבודג\\new\\resources\\mk'+ str(mkNum) + 'Data.csv' raw_data = open(filename, 'rt', encoding="utf8") reader = csv.reader(raw_data, delimiter=',', quoting=csv.QUOTE_NONE) x = list(reader) header = x[0] data = np.array(x[1:]).astype('float') The var header should be an

Python - Reading and writing csv files with utf-8 encoding

做~自己de王妃 提交于 2021-02-07 13:36:43
问题 I'm trying to read a csv file the its header contains foreign characters and I'm having a lot of problems with this. first of all, I'm reading the file with a simple csv.reader filename = 'C:\\Users\\yuval\\Desktop\\בית ספר\\עבודג\\new\\resources\\mk'+ str(mkNum) + 'Data.csv' raw_data = open(filename, 'rt', encoding="utf8") reader = csv.reader(raw_data, delimiter=',', quoting=csv.QUOTE_NONE) x = list(reader) header = x[0] data = np.array(x[1:]).astype('float') The var header should be an

PotgreSQL- ERROR: invalid byte sequence for encoding “UTF8”: 0xeb 0x6e 0x74

被刻印的时光 ゝ 提交于 2021-02-07 11:00:46
问题 I am working on PostgreSQL and getting below error during insert statement execution from batch script(command line). ERROR: invalid byte sequence for encoding "UTF8": 0xeb 0x6e 0x74 I have checked client_encoding by show client_encoding command and it is showing UTF-8. Also checked database properties by using command select * from pg_database where datname='<mydbName>' In Output : datcollate = English_United States.1252 datctype = English_United States.1252 How to resolve this issue? 回答1:

PotgreSQL- ERROR: invalid byte sequence for encoding “UTF8”: 0xeb 0x6e 0x74

允我心安 提交于 2021-02-07 11:00:31
问题 I am working on PostgreSQL and getting below error during insert statement execution from batch script(command line). ERROR: invalid byte sequence for encoding "UTF8": 0xeb 0x6e 0x74 I have checked client_encoding by show client_encoding command and it is showing UTF-8. Also checked database properties by using command select * from pg_database where datname='<mydbName>' In Output : datcollate = English_United States.1252 datctype = English_United States.1252 How to resolve this issue? 回答1:

Defining the character encoding of a JavaScript source file

情到浓时终转凉″ 提交于 2021-02-07 04:45:09
问题 I would like to print a status message to my German users, which contains umlauts (ä/ü/ö). I also would like them be in the source file rather than having to download and parse some extra file just for the messages. However, I can't seem to find a way to define the encoding of a JS source file. Is there something like HTML's http-equiv ? Or should I define the encoding in the HTTP header? When I simply encode the file in UTF-8 an serve it, IE displays garbage. 回答1: Sending the encoding in the