encoding

UnicodeDecodeError: in python 2.7

坚强是说给别人听的谎言 提交于 2019-12-24 15:08:18
问题 I am working with the VirusTotal api, exactly with this: https://www.virustotal.com/es/documentation/public-api/#scanning-files This is the part of my scritp where im having problems: def scanAFile(fileToScan): host = "www.virustotal.com" selector = "https://www.virustotal.com/vtapi/v2/file/scan" fields = [("apikey", myPublicKey)] file_to_send = open(fileToScan, "rb").read() files = [("file", fileToScan, file_to_send)] json = postfile.post_multipart(host, selector, fields, files) return

What should be the data type for the hashed value of a password encrypted using PBKDF2?

泄露秘密 提交于 2019-12-24 14:51:14
问题 I am trying to learn to use PBKDF2 hash functions for storing passwords in the database. I have a rough draft of the procedure that I'll be using to generate the hashed function. But while I am creating the table in PL/SQL Developer which will hold the generated hashed password, what should I declare the data type for the encrypted password variable? It might be a lame question but I'm trying to learn online. It would be a huge help if I can get links for further study as well. thank you.

Encoding and decoding data the way MVC likes it

孤街浪徒 提交于 2019-12-24 14:49:28
问题 I get data from MVC and encode it using HttpUtility.HtmlEncode . The problem is that MVC is not fond of form values containing the ampersand (&) symbol. For example, this... HttpUtility.HtmlEncode("'"); ...results in ' . I fetch it on a GET , but if I submit this on a POST , I see the following action error: Exception = {"A potentially dangerous Request.Form value was detected from the client (selection=\"'...\")."} How can I encode my data on a GET in a way that makes MVC happy on a POST ? I

label above points with rChart Failed with Chinese ,

99封情书 提交于 2019-12-24 14:40:10
问题 My problem is just like label above points with rChart *but my label contains Chinese code, my code is like this: library(rCharts) age <- c(1:20) tall <- seq(0.5, 1.90, length = 20) name <- rep(c("运营成本由一降为2","游戏进行推广","开始安全运行","无事件","this is"),4) Encoding(name)<-'UTF-8' df <- data.frame(age = age, tall = tall,name=name) n1 <- nPlot(age ~ tall ,data = df, type = "scatterChart") n1$xAxis(axisLabel = "the age") n1$yAxis(axisLabel = "the tall", width = 50) n1$chart(tooltipContent = "#! function

Android - java.lang.NoSuchFieldError: android.graphics.Bitmap$CompressFormat.WEBP

自作多情 提交于 2019-12-24 14:24:17
问题 I'm trying to use a very simple piece of code that has been supported since API 1. if (bitmap != null) { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.WEBP, IMAGE_QUALITY, byteArrayOutputStream); byte[] bytes = byteArrayOutputStream.toByteArray(); result = Base64.encodeToString(bytes, Base64.DEFAULT); } somehow, bitmap.compress(Bitmap.CompressFormat.WEBP, IMAGE_QUALITY, byteArrayOutputStream); gives me that weird error: java

About the use of Encoding function

故事扮演 提交于 2019-12-24 14:10:08
问题 I am using the following code for importing special characters in R: Encoding(self$Data$Skills) <- "UTF-8" But when I change the name of the column with: colnames(self$Data) <- 'skills2' and run again: Encoding(self$Data$skills2) <- "UTF-8" I have the following error: Error in `Encoding<-`(`*tmp*`, value = "UTF-8") : a character vector argument expected I do not understand why is this happening. Any idea? Additionally, the same is happening if I want to sample data from this dataframe. Using:

how to read text copied from web to txt file using python

白昼怎懂夜的黑 提交于 2019-12-24 12:44:35
问题 I'm learning how to read text files. I used this way: f=open("sample.txt") print(f.read()) It worked fine if I typed the txt file myself. But when I copied text from a news article on the web, it produced the following error: UnicodeEncodeError: 'charmap' codec can't encode charater '\u2014' in position 738: character maps to undefined I tried changing the Encoding setting in Notepad++ to UTF-8 as I read somewhere it is due to that I also tried using: f=open("sample.txt",encoding='utf-8')

PCRE Encoding Support

天涯浪子 提交于 2019-12-24 12:24:29
问题 I saw in the PCRE Documentation that PCRE support UTF-8 and Unicode general category properties, but i dont see where it say the Native encoding support. If you say that support ISO-8859-1: where can i found info about that? In A Nutshell: Ive compared & im guessing that the encoding supported by PHP is windows-1252 and not the ISO-8859-1 encoding. if(preg_match('/€/',"\x80")) echo "Match"; ISO-8859-1 doesn't have the '€' in that position. Windows-1252 does. Or dependes of the system? So wich

Decoding non standard characters to UTF 8 in Python

大城市里の小女人 提交于 2019-12-24 12:11:10
问题 I have a program that takes in byte-encoded text via a webhook in Django (written in Python). I have decoding from byte -> utf-8 working for normal letters, but it breaks when an apostrophe ( ' ) is sent in. I have this written to decode the text: encoded = request.body decoded = parse_qs(encoded) body = decoded[b'body'][0].decode("utf-8") And this is the error: UnicodeEncodeError: 'ascii' codec can't encode character '\u2019' in position 5: ordinal not in range(128) I'd like for it to

In C#, How can I copy a file with arbitrary encoding, reading line by line, without adding or deleting a newline

百般思念 提交于 2019-12-24 11:53:34
问题 I need to be able to take a text file with unknown encoding (e.g., UTF-8, UTF-16, ...) and copy it line by line, making specific changes as I go. In this example, I am changing the encoding, however there are other uses for this kind of processing. What I can't figure out is how to determine if the last line has a newline! Some programs care about the difference between a file with these records: Rec1<newline> Rec2<newline> And a file with these: Rec1<newline> Rec2 How can I tell the