encoding

Which file encodings are supported for Python 3 source files?

强颜欢笑 提交于 2020-01-09 11:49:31
问题 Before you go telling me to read PEP 0263, keep reading... I can't find any documentation that details which file encodings are supported for Python 3 source files . I've found hundreds (thousands?) of questions, answers, posts, emails, etc. about how to declare - at the top of your source file - the encoding of that source file, but none of them answer my question. Bear with me and imagine doing (or actually try) the following: Open Notepad (I'm using regular old Notepad on Windows 7, but I

Node Buffers, from utf8 to binary

断了今生、忘了曾经 提交于 2020-01-09 10:10:14
问题 I'm receiving data as utf8 from a source and this data was originally in binary form (it was a Buffer ). I have to convert back this data to a Buffer . I'm having a hard time figuring how to do this. Here's a small sample that shows my problem: var hexString = 'e61b08020304e61c09020304e61d0a020304e61e65'; var buffer1 = new Buffer(hexString, 'hex'); var str = buffer1.toString('utf8'); var buffer2 = new Buffer(str, 'utf8'); console.log('original content:', hexString); console.log('buffer1

Node Buffers, from utf8 to binary

谁都会走 提交于 2020-01-09 10:10:10
问题 I'm receiving data as utf8 from a source and this data was originally in binary form (it was a Buffer ). I have to convert back this data to a Buffer . I'm having a hard time figuring how to do this. Here's a small sample that shows my problem: var hexString = 'e61b08020304e61c09020304e61d0a020304e61e65'; var buffer1 = new Buffer(hexString, 'hex'); var str = buffer1.toString('utf8'); var buffer2 = new Buffer(str, 'utf8'); console.log('original content:', hexString); console.log('buffer1

decodeURIComponent vs unescape, what is wrong with unescape?

杀马特。学长 韩版系。学妹 提交于 2020-01-09 02:00:28
问题 In answering another question I became aware that my Javascript/DOM knowledge had become a bit out of date in that I am still using escape / unescape to encode the contents of URL components whereas it appears I should now be using encodeURIComponent / decodeURIComponent instead. What I want to know is what is wrong with escape / unescape ? There are some vague suggestions that there is some sort of problem around Unicode characters, but I can't find any definite explanation. My web

decodeURIComponent vs unescape, what is wrong with unescape?

随声附和 提交于 2020-01-09 01:59:35
问题 In answering another question I became aware that my Javascript/DOM knowledge had become a bit out of date in that I am still using escape / unescape to encode the contents of URL components whereas it appears I should now be using encodeURIComponent / decodeURIComponent instead. What I want to know is what is wrong with escape / unescape ? There are some vague suggestions that there is some sort of problem around Unicode characters, but I can't find any definite explanation. My web

decodeURIComponent vs unescape, what is wrong with unescape?

无人久伴 提交于 2020-01-09 01:58:26
问题 In answering another question I became aware that my Javascript/DOM knowledge had become a bit out of date in that I am still using escape / unescape to encode the contents of URL components whereas it appears I should now be using encodeURIComponent / decodeURIComponent instead. What I want to know is what is wrong with escape / unescape ? There are some vague suggestions that there is some sort of problem around Unicode characters, but I can't find any definite explanation. My web

What is “=C2=A0” in MIME encoded, quoted-printable text?

こ雲淡風輕ζ 提交于 2020-01-08 16:26:25
问题 This is an example raw email I am trying to parse: MIME-version: 1.0 Content-type: text/html; charset=UTF-8 Content-transfer-encoding: quoted-printable X-Mailer: Verizon Webmail X-Originating-IP: [x.x.x.x] =C2=A0test testing testing 123 What is =C2=A0? I have tried a half dozen quoted-printable parsers, but none handle this correctly. How would one properly parse this in C#? Honestly, for now, I'm coding: //TODO WTF encoded = encoded.Replace("=C2=A0", ""); Because I can't figure out why that

What is “=C2=A0” in MIME encoded, quoted-printable text?

蹲街弑〆低调 提交于 2020-01-08 16:23:26
问题 This is an example raw email I am trying to parse: MIME-version: 1.0 Content-type: text/html; charset=UTF-8 Content-transfer-encoding: quoted-printable X-Mailer: Verizon Webmail X-Originating-IP: [x.x.x.x] =C2=A0test testing testing 123 What is =C2=A0? I have tried a half dozen quoted-printable parsers, but none handle this correctly. How would one properly parse this in C#? Honestly, for now, I'm coding: //TODO WTF encoded = encoded.Replace("=C2=A0", ""); Because I can't figure out why that

Java - Convert String to valid URI object

杀马特。学长 韩版系。学妹 提交于 2020-01-08 16:01:30
问题 I am trying to get a java.net.URI object from a String . The string has some characters which will need to be replaced by their percentage escape sequences. But when I use URLEncoder to encode the String with UTF-8 encoding, even the / are replaced with their escape sequences. How can I get a valid encoded URL from a String object? http://www.google.com?q=a b gives http%3A%2F%2www.google.com... whereas I want the output to be http://www.google.com?q=a%20b Can someone please tell me how to

Page displaying '?', instead of 'é'

早过忘川 提交于 2020-01-07 05:46:06
问题 I am retriving data from oracle11g and displaying the data on IE8 and IE9 browser, but the couldn't display some special characters (eg. é) In my webpage, I have explicitly declare 'UTF-8' encoding. For my tomcat webserver, the server.xml <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" useBodyEncodingForURI="true"/> I read some other questions in stackflow, they mentioned to also ensure the database connection is using 'UTF-8' too.