character-encoding

Python imaplib: Display non-ASCII characters correctly

点点圈 提交于 2021-01-27 18:26:16
问题 I am using Python 3.5 and imaplib to fetch an e-mail from GMail and print its body. The body contains non-ASCII characters. These are 'encoded' in a strange way and I cannot find out how to fix this. import email import imaplib c = imaplib.IMAP4_SSL('imap.gmail.com') c.login('example@gmail.com', 'password') c.select('Inbox') _, data = c.fetch(b'12345', '(RFC822)') mail = data[0][1] message = email.message_from_bytes(mail) payload = message.get_payload() body = mail[0].as_string() print(body)

Python googletrans encoding weird chars

偶尔善良 提交于 2021-01-27 17:04:07
问题 I have an ui which takes german language among other things and translate these in english sentences. # -*- coding: utf-8 -*- from googletrans import Translator def tr(s) translator = Translator() return translator.translate(wordDE,src='de',dest='en').text Sometimes I get weird characters from the translator. For example: DE: Pascal und PHP sind Programmiersprachen für Softwareentwickler und Ingenieure. googletrans EN(utf8): Pascal and PHP are programming languages ​​for software developers

Python googletrans encoding weird chars

痞子三分冷 提交于 2021-01-27 16:57:43
问题 I have an ui which takes german language among other things and translate these in english sentences. # -*- coding: utf-8 -*- from googletrans import Translator def tr(s) translator = Translator() return translator.translate(wordDE,src='de',dest='en').text Sometimes I get weird characters from the translator. For example: DE: Pascal und PHP sind Programmiersprachen für Softwareentwickler und Ingenieure. googletrans EN(utf8): Pascal and PHP are programming languages ​​for software developers

Strange character when reading NFC tag

╄→尐↘猪︶ㄣ 提交于 2021-01-27 16:45:09
问题 I am trying to read an NFC tag using Android. I'm a beekeeper and this is to ID my hives when I approach them. I have searched here but I am still having issues reading the tag. I want to read the text, but when it reads, there is a square-like character and characters displayed like " Ten" before the desired text. Here is the code I'm using. I know that the payload bytes have to be correct and I have tried changing them but to no avail. private static NdefMessage getTestMessage() { byte[]

How can i open a Windows-1255 encoded file in Node.js?

佐手、 提交于 2021-01-27 05:01:54
问题 I have a file in Windows-1255 (Hebrew) encoding, and i'd like to be able to access it in Node.js. I tried opening the file with fs.readFile , and it gives me a Buffer that i can't do anything with. I tried setting the encoding to Windows-1255 , but that wasn't recognized. I also checked out the windows-1255 package, but i couldn't decode with that, because fs.readFile either gives a Buffer or a UTF8 string, and the package requires a 1255-encoded string. How can i read a Windows-1255 -encoded

In what 8-bit character set is 0x9d meaningful?

依然范特西╮ 提交于 2021-01-26 09:46:37
问题 In what 8-bit ASCII-like character set for English is 0x9d meaningful? I'm cleaning up some old data files, and occasionally finding a 0x9d in otherwise-ASCII text. (No, it's not UTF-8.) It's not valid in Windows-1252. The Python "latin-1" codec translates it to Unicode 0x9D, which is "Operating System Command". That makes little sense. In Unicode you get a box with [009d]. (In Python, you can convert anything to Latin-1 without errors being raised, but that doesn't mean it's meaningful to do

Arabic labels do not display correctly in Geoserver

对着背影说爱祢 提交于 2021-01-24 08:17:13
问题 I have geoserver installed with Tomcat and the text labeling do not display correctly . where can i set the Arabic encoding in geosever? the labeling appear well in QGIS but when i publish it in geoserver i get this problem . ]1 The shape file Here Is the SLD : <?xml version="1.0" encoding="UTF-8"?> <sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" version="1.0.0">

java.io.File: accessing files with invalid filename encodings

こ雲淡風輕ζ 提交于 2021-01-22 06:45:14
问题 Because the constructor of java.io.File takes a java.lang.String as argument, there is seemingly no possibility to tell it which filename encoding to expect when accessing the filesystem layer. So when you generally use UTF-8 as filename encoding and there is some filename containing an umlaut encoded as ISO-8859-1, you are basically ** . Is this correct? Update: because noone seemingly gets it, try it yourself: when creating a new file, the environment variable LC_ALL (on Linux) determines

java.io.File: accessing files with invalid filename encodings

早过忘川 提交于 2021-01-22 06:44:53
问题 Because the constructor of java.io.File takes a java.lang.String as argument, there is seemingly no possibility to tell it which filename encoding to expect when accessing the filesystem layer. So when you generally use UTF-8 as filename encoding and there is some filename containing an umlaut encoded as ISO-8859-1, you are basically ** . Is this correct? Update: because noone seemingly gets it, try it yourself: when creating a new file, the environment variable LC_ALL (on Linux) determines

UnicodeEncodeError: 'charmap' codec can't encode character '\ufeff' in position 0: character maps to <undefined>

女生的网名这么多〃 提交于 2021-01-20 11:56:38
问题 I'm working on an application which is using utf-8 encoding. For debugging purposes I need to print the text. If I use print() directly with variable containing my unicode string, ex- print(pred_str) . I get this error: UnicodeEncodeError: 'charmap' codec can't encode character '\ufeff' in position 0: character maps to So I tried print(pred_str.encode('utf-8')) and my output looks like this: b'\xef\xbb\xbfpudgala-dharma-nair\xc4\x81tmyayo\xe1\xb8\xa5 apratipanna-vipratipann\xc4\x81n\xc4\x81m'