encoding

What are some common ways that smart quotes will be incorrectly encoded?

我怕爱的太早我们不能终老 提交于 2020-01-02 07:07:10
问题 Smart quotes cause problems when they are saved in one encoding and then rendered/viewed using a different encoding. What are some ways that smart quotes will appear when rendered incorrectly? I'm trying to solve the problem where you see an incorrect character encoding and can then say, "Oh, those should be smart quotes." 回答1: The most common encoding mixup is probably UTF-8 versus ANSI/Latin1. The ANSI/Latin1 encoding of “ ‘ ’ ” is [93] [91] [92] [94] hexadecimal. If interpreted as UTF-8,

How to Extract Zip Files with non-Unicode non-Latin Filenames?

蹲街弑〆低调 提交于 2020-01-02 07:04:53
问题 Sometimes you come by Zip files with file or directory with some unrecognized characters in the names so you can't extract them. What tools do you use to extract them in properly converted filenames? 回答1: I searched the web but failed to find a good script. So out of necessity I wrote a Python script myself. Hope it comes handy for someone. Any suggestions are welcome, especially if you know this will not work in some special cases. Please don't pick on the untidy coding style. import os,sys

XML Unicode Safe Encoding

╄→尐↘猪︶ㄣ 提交于 2020-01-02 06:01:34
问题 I'm looking for a way to encode an XML document using the #&233; encoding. Using this basic code var xmlDoc = new XmlDocument(); xmlDoc.Load(@"D:\Temp\XmlDocBase.xml"); xmlDoc.Save(@"D:\Temp\XmlDocBaseCopy.xml"); my Xml document pass from: <?xml version="1.0"?> <Tag1> <comment>entité</comment> </Tag1> to <?xml version="1.0"?> <Tag1> <comment>entité</comment> </Tag1> Regards 回答1: You can force encoding that does not support all unicode characters (i.e. ASCII). As result writer will be forced

How do I determine if an email is Base64 encoded?

江枫思渺然 提交于 2020-01-02 05:15:10
问题 I am having difficulty determining if the body of a text email message is base64 encoded. if it is then use this line of code; making use of jython 2.2.1 dirty=base64.decodestring(dirty) else continue as normal. This is the code I have atm. What line of code will allow me to extract this from the email: "Content-Transfer-Encoding: base64" import email, email.Message import base64 def _get_email_body(self): try: parts=self._email.get_payload() check=parts[0].get_content_type() if check=="text

Why shouldn't I use spaces in file names when I can use a code equivalent? [closed]

北城以北 提交于 2020-01-02 04:41:07
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . I've read all over the place NOT to use spaces in file names intended for use on the Web, e.g. URLs. I don't understand what's wrong with using " %20 " to replace them when referring to the name in my code. It seems more appropriate to use this replacement because I'm then

Java buffered base64 encoder for streams

蹲街弑〆低调 提交于 2020-01-02 04:15:11
问题 I have lots of PDF files that I need to get its content encoded using base64. I have an Akka app which fetch the files as stream and distributes to many workers to encode these files and returns the string base64 for each file. I got a basic solution for encoding: org.apache.commons.codec.binary.Base64InputStream; ... Base64InputStream b64IStream = null; InputStreamReader reader = null; BufferedReader br = null; StringBuilder sb = new StringBuilder(); try { b64IStream = new Base64InputStream

ActiveRecord returns data in ASCII-8Bit Under Ruby 1.9.2-rc1

ⅰ亾dé卋堺 提交于 2020-01-02 04:11:15
问题 Further to the title, when loading data from ActiveRecord the encoding is always set to ASCII-8Bit in spite of my best efforts to force the encoding. I have entered as much detail as possible here to try and build a good error report someone could use to help me out! The project is using the following technologies: Padrino Framework Ruby 1.9.2-rc2 (Also 1.9.1 and 1.9.2-preview3) ActiveRecord MySQL (Full List) $ bundle show | ack '(record|padrino)' * activerecord (2.3.8) * padrino (0.9.14) *

MySQL and Python Select Statement Issues

淺唱寂寞╮ 提交于 2020-01-02 04:11:12
问题 Thanks for taking the time to read this. It's going to be a long post to explain the problem. I haven't been able to find an answer in all the usual sources. Problem: I am having an issue with using the select statement with python to recall data from a table in a mysql database. System and versions: Linux ubuntu 2.6.38-14-generic #58-Ubuntu SMP Tue Mar 27 20:04:55 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux Python: 2.7.1+ MySql: Server version: 5.1.62-0ubuntu0.11.04.1 (Ubuntu) Here's the table:

Pitfalls in my code for detecting text file encoding with Python?

血红的双手。 提交于 2020-01-02 04:08:09
问题 I know more about bicycle repair, chainsaw use and trench safety than I do Python or text encoding; with that in mind... Python text encoding seems to be a perennial issue (my own question: Searching text files' contents with various encodings with Python?, and others I've read: 1, 2. I've taken a crack at writing some code to guess the encoding below. In limited testing this code seems to work for my purposes* without me having to know an excess about the first three bytes of text encoding

encoding to UTF-8 in email

旧街凉风 提交于 2020-01-02 03:50:46
问题 I have a client that is receiving email incorrectly encoded. I am using the System.Net.Mail class and setting the body encoding to UTF-8. I have done a bit of reading and since I have to set the body of the email as a string encoding the data to a UTF-8 byte array really does nothing for me since I have to convert is back to a string that is UTF-16. Correct? when I send: Il s'agit d'un message de test pour déterminer comment le système va gérer les messages envoyés à l'aide des caractères