encoding

How can I encode and decode percent-encoded (URL encoded) strings in Python?

我怕爱的太早我们不能终老 提交于 2020-01-14 18:43:18
问题 I wrote a simple application which downloads articles from wiki pages. When I search, for example for a firstname Lech , my code returns strings like Lech_Kaczy%C5%84ski or Lech_Pozna%C5%84 instead of Lech_Kaczyński and Lech_Poznań . How can I decode those characters to ordinary polish letters? I tried to use: urllib.unquote(text) but then got Lech_Kaczy\xc5\x84ski , Lech_Pozna\xc5\x84 instead of Lech_Kaczyński and Lech_Poznań . I have in my code: # -*- coding: utf-8 -*- import sys reload(sys

php zip contents encoding

我与影子孤独终老i 提交于 2020-01-14 14:42:50
问题 I create some .txt files (with greek characters) via a php script, with UTF-8 encoding. When i am trying to download and read these files from ftp everything works fine (no encoding problems). When I zip these files to a zip archive, I am facing encoding problem with all greek characters and newLines chars. zip script: $zip = new ZipArchive(); $filename = "my_zip.zip"; if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) { exit("cannot open <$filename>\n"); } $files = glob('users/'.$_SESSION

Editing XML with PowerShell and “file format” error

扶醉桌前 提交于 2020-01-14 14:15:53
问题 I am using the HyperV Module from Codeplex to do a "config only" export from a 2008R2 Hyper-V server. In order to import the configuration on another HyperV server, I need to edit the value of CopyVMStorage in the EXP file. This file is an XML file. I wrote the following code in PowerShell to do the update for me. The variable $existing is the existing exp file. $xml = [xml](get-content $existing) $xpath = '//PROPERTY[@NAME ="CopyVmStorage"]' foreach ($node in $xml.SelectNodes($xpath)) {$node

Editing XML with PowerShell and “file format” error

流过昼夜 提交于 2020-01-14 14:15:14
问题 I am using the HyperV Module from Codeplex to do a "config only" export from a 2008R2 Hyper-V server. In order to import the configuration on another HyperV server, I need to edit the value of CopyVMStorage in the EXP file. This file is an XML file. I wrote the following code in PowerShell to do the update for me. The variable $existing is the existing exp file. $xml = [xml](get-content $existing) $xpath = '//PROPERTY[@NAME ="CopyVmStorage"]' foreach ($node in $xml.SelectNodes($xpath)) {$node

PHP and character encoding problem with  character

我与影子孤独终老i 提交于 2020-01-14 10:46:27
问题 I'm having a problem where PHP (5.2) cannot find the character 'Â' in a string, though it is clearly there. I realize the underlying problem has to do with character encoding, but unfortunately I have no control over the source content. I receive it as UTF-8, with those characters already in the string. I would simply like to remove it from the string. strpos(), str_replace(), preg_replace(), trim(), etc. Cannot correctly identify it. My string is this: "Â Â Â A lot of couples throughout the

Correct encoding for ID3 Tags in iOS

我的梦境 提交于 2020-01-14 06:52:09
问题 I'm trying to get ID3 tags from a bunch of mp3 files in my project. AudioFileGetProperty(audioFile, kAudioFilePropertyInfoDictionary, &size, &metadataDictionary); If the tag doesn't contain cyrillic symbols, the output looks OK on the device. However I sometimes get values like this one: album = "\U00ce\U00f2\U00ea\U00f0\U00fb\U00f2\U00ee\U00e5 \U00d0\U00e0\U00e4\U00e8\U00ee 102.5FM"; "approximate duration in seconds" = "260.623"; and it leads to distorted symbols display (http://d.pr/i/X9wG)

Unit testing for unicode support

可紊 提交于 2020-01-14 04:48:06
问题 I'm trying to convert to unicode and create some unit tests to ensure that unicode is working. Here is my current code, which fails on the mb_detect_encoding() line, and which I'm also not sure whether it is a valid test of unicode support: function testMultiLingualEncodings(){ // Create this string via a heredoc. $original = ' A good day, World! Schönen Tag, Welt! Une bonne journée, tout le monde! يوم جيد، العالم 좋은 일, 세계! Một ngày tốt lành, thế giới! こんにちは、世界! '; // Contains international

how to remove non utf 8 code and save as a csv file python

巧了我就是萌 提交于 2020-01-14 03:13:20
问题 I have some amazon review data and I have converted from the text format to CSV format successfully, now the problem is when I trying to read it into a dataframe using pandas, i got error msg: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8 in position 13: invalid start byte I understand there must be some non utf-8 in the review raw data, how can I remove the non UTF-8 and save to another CSV file? thank you! EDIT1: Here is the code i convert to text to csv: import csv import string

how to remove non utf 8 code and save as a csv file python

旧巷老猫 提交于 2020-01-14 03:13:11
问题 I have some amazon review data and I have converted from the text format to CSV format successfully, now the problem is when I trying to read it into a dataframe using pandas, i got error msg: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8 in position 13: invalid start byte I understand there must be some non utf-8 in the review raw data, how can I remove the non UTF-8 and save to another CSV file? thank you! EDIT1: Here is the code i convert to text to csv: import csv import string

How to encode base64 in Delphi 6? [duplicate]

怎甘沉沦 提交于 2020-01-14 02:35:05
问题 This question already has answers here : Binary to Base64 (Delphi) (2 answers) Closed 6 years ago . I need to encode a pdf document to base64 in Delphi6. Can anyone help me? 回答1: You can use the EncdDecd unit that is supplied with Delphi. The function you need is EncodeStream . You simply need to create two streams, one for input and one for output. If you are working with files then you should create TFileStream instances. Once you have your two file streams created, all you need is: