encoding

MySQL : strange LENGTH() behaviour on utf8 string

余生颓废 提交于 2021-02-08 12:18:05
问题 I am doing unit tests on requests generators, and I get in trouble with LENGTH function. I have 2 requests that follows each other : SHOW VARIABLES LIKE '%character%' Returns the following result : array(8) { [0] => array(2) { 'Variable_name' => string(20) "character_set_client" 'Value' => string(4) "utf8" } [1] => array(2) { 'Variable_name' => string(24) "character_set_connection" 'Value' => string(4) "utf8" } [2] => array(2) { 'Variable_name' => string(22) "character_set_database" 'Value' =

Get image from http GET response as base64 String

我怕爱的太早我们不能终老 提交于 2021-02-08 11:32:32
问题 When my GET request for an image returns an encoded string like ‰PNGØßn¥àí»Øèª¯ÐPÒäœ?Å'Üë²... How can I get the image as a base64 encoded String, instead of whatever encoding this is? String url = http://i.stack.imgur.com/tKsDb.png; try{ URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); // optional default is GET con.setRequestMethod("GET"); //add request header con.setRequestProperty("User-Agent", "Mozilla/5.0"); int responseCode = con.getResponseCode(

python 3.4 encoding in windows 8.1

匆匆过客 提交于 2021-02-08 10:33:12
问题 I use the script mentioned in this question, to check the encoding: import sys, locale, os print(sys.stdout.encoding) print(sys.stdout.isatty()) print(locale.getpreferredencoding()) print(sys.getfilesystemencoding()) print(os.environ["PYTHONIOENCODING"]) print(chr(246), chr(9786), chr(9787)) and I obtain (python 3.4, windows 8.1): windows-1252 False cp1252 mbcs windows-1252 ö Traceback (most recent call last): File "C:/Users/.../UTF8-comprovacio.py", line 8, in <module> print(chr(246), chr

Most efficient way to save binary code to file

£可爱£侵袭症+ 提交于 2021-02-08 10:24:56
问题 I have a string that only contains 1 and 0 and I need to save this to a .txt-File. I also want it to be as small as possible. Since I have binary code, I can turn it into pretty much everything. Saving it as binary is not an option, since apparently every character will be a whole byte, even if it's a 1 or a 0 . I thought about turning my string into an Array of Byte but trying to convert "11111111" to Byte gave me a System.OverflowException . My next thought was using an ASCII Codepage or

Beautiful Soup conversion of Unicode characters to HTML entities

╄→гoц情女王★ 提交于 2021-02-08 09:16:00
问题 This error occurs after loading the document into beautifulsoup The document contains entities like &ldquo; which gets converted to ΓÇ£ I want to output the html entities &ldquo; 回答1: use this refernce link from bs4 import BeautifulSoup soup = BeautifulSoup(html_doc) print(soup.prettify(formatter="html")) 来源: https://stackoverflow.com/questions/23191624/beautiful-soup-conversion-of-unicode-characters-to-html-entities

Beautiful Soup conversion of Unicode characters to HTML entities

ぐ巨炮叔叔 提交于 2021-02-08 09:15:28
问题 This error occurs after loading the document into beautifulsoup The document contains entities like &ldquo; which gets converted to ΓÇ£ I want to output the html entities &ldquo; 回答1: use this refernce link from bs4 import BeautifulSoup soup = BeautifulSoup(html_doc) print(soup.prettify(formatter="html")) 来源: https://stackoverflow.com/questions/23191624/beautiful-soup-conversion-of-unicode-characters-to-html-entities

“SFC” output redirection formatting issue - Powershell / Batch

大憨熊 提交于 2021-02-08 08:35:23
问题 I'm working on a powershell script in which several commands output are shown in the window and appended to a file or a variable. It worked correctly until I used the sfc command. When piped or redirected, the output is "broken": > sfc /? Vérificateur de ressources Microsoft (R) Windows (R) version 6.0[...] > sfc /? | Tee-Object -Variable content V Ú r i f i c a t e u r d e r e s s o u r c e s M i c r o s o f t ( R ) W i n d o w s ( R ) v e r s i o á 6 . 0[...] Are there other commands like

Python decoding from iso-8859-5

荒凉一梦 提交于 2021-02-08 08:34:13
问题 When I parse my email messages via python email.parser.Parser, I had a lot of strings like this: =?ISO-8859-5?Q?=C0=D5=D5=E1=E2=E0_=BF=DB=D0=E2=D5=D6=D5=D9_?= How can i decode this to utf-8 using python? 回答1: Your input is quoted-printable encoded text. You can use the module quopri to handle that: import quopri incode = '=?ISO-8859-5?Q?=C0=D5=D5=E1=E2=E0_=BF=DB=D0=E2=D5=D6=D5=D9_?=' inencoding = incode[2:12] # 'ISO-8859-5' intext = incode[15:-2] result = quopri.decodestring(intext).encode

Python - decode ('utf-8') issue

这一生的挚爱 提交于 2021-02-08 07:41:13
问题 I am very new to Python.Please help me fix this issue. I am trying to get the revenue from the link below : https://www.google.co.in/?gfe_rd=cr&ei=kFFsWYyPEqvM8AeF7Y2IDQ&gws_rd=ssl#q=adp+revenue&stick=H4sIAAAAAAAAAOPgE-LUz9U3MMkozijTUskot9JPzs_JSU0uyczP088vSk_My6xKBHGKrYpSy1LzSlMBIRiSrDMAAAA&spf=1500270991898 I am using below commands : import re import urllib.request data=urllib.request.urlopen(url).read() data1=data.decode("utf-8") Issue : UnicodeDecodeError: 'utf-8' codec can't decode byte

Python - decode ('utf-8') issue

心不动则不痛 提交于 2021-02-08 07:41:09
问题 I am very new to Python.Please help me fix this issue. I am trying to get the revenue from the link below : https://www.google.co.in/?gfe_rd=cr&ei=kFFsWYyPEqvM8AeF7Y2IDQ&gws_rd=ssl#q=adp+revenue&stick=H4sIAAAAAAAAAOPgE-LUz9U3MMkozijTUskot9JPzs_JSU0uyczP088vSk_My6xKBHGKrYpSy1LzSlMBIRiSrDMAAAA&spf=1500270991898 I am using below commands : import re import urllib.request data=urllib.request.urlopen(url).read() data1=data.decode("utf-8") Issue : UnicodeDecodeError: 'utf-8' codec can't decode byte