decoding

Encode base64 and Decode base64 using delphi 2007

核能气质少年 提交于 2019-12-03 21:06:58
I have to encode an array of bytes to a base64 string (and decode this string) on an old Delphi 2007. How could I do? Further Informations: I've tried synapse (As suggested here Binary to Base64 (Delphi) ). Indy ships with Delphi, and has TIdEncoderMIME and TIdDecoderMIME classes for handling base64. For example: uses ..., IdCoder, IdCoderMIME; var Bytes: TIdBytes; Base64String: String; begin //... Bytes := ...; // array of bytes //... Base64String := TIdEncoderMIME.EncodeBytes(Bytes); //... Bytes := TIdDecoderMIME.DecodeBytes(Base64String); //... end; There are also methods for encoding

How to set decode pixel format in libavcodec?

大兔子大兔子 提交于 2019-12-03 16:49:38
问题 I decode video via libavcodec, using the following code: //Open input file if(avformat_open_input(&ctx, filename, NULL, NULL)!=0) return FALSE; // Couldn't open file if(avformat_find_stream_info(ctx, NULL)<0) return FALSE; // Couldn't find stream information videoStream = -1; //find video stream for(i=0; i<ctx->nb_streams; i++) { if((ctx->streams[i])->codec->codec_type==AVMEDIA_TYPE_VIDEO) { videoStream=i; break; } } if (videoStream == -1) return FALSE; // Didn't find a video stream video

Why does chardet say my UTF-8-encoded string (originally decoded from ISO-8859-1) is ASCII?

孤人 提交于 2019-12-03 13:43:21
I'm trying to convert ascii characters to utf-8. This little example below still returns ascii characters: chunk = chunk.decode('ISO-8859-1').encode('UTF-8') print chardet.detect(chunk[0:2000]) It returns: {'confidence': 1.0, 'encoding': 'ascii'} How come? Quoting from Python's documentation : UTF-8 has several convenient properties: It can handle any Unicode code point. A Unicode string is turned into a string of bytes containing no embedded zero bytes. This avoids byte-ordering issues, and means UTF-8 strings can be processed by C functions such as strcpy() and sent through protocols that

Decode a websocket frame

我怕爱的太早我们不能终老 提交于 2019-12-03 13:34:30
I am trying to decode a websocket frame, but I'm not successful when it comes to decoding the extended payload. Here what I did achieve so far: char *in = data; char *buffer; unsigned int i; unsigned char mask[4]; unsigned int packet_length = 0; int rc; /* Expect a finished text frame. */ assert(in[0] == '\x81'); packet_length = ((unsigned char) in[1]) & 0x7f; mask[0] = in[2]; mask[1] = in[3]; mask[2] = in[4]; mask[3] = in[5]; if (packet_length <= 125) { **// This decoding works** /* Unmask the payload. */ for (i = 0; i < packet_length; i++) in[6 + i] ^= mask[i % 4]; rc = asprintf(&buffer, "%.

Can I turn off implicit Python unicode conversions to find my mixed-strings bugs?

廉价感情. 提交于 2019-12-03 13:21:17
问题 When profiling our code I was surprised to find millions of calls to C:\Python26\lib\encodings\utf_8.py:15(decode) I started debugging and found that across our code base there are many small bugs, usually comparing a string to a unicode or adding a sting and a unicode. Python graciously decodes the strings and performs the following operations in unicode. How kind. But expensive! I am fluent in unicode, having read Joel Spolsky and Dive Into Python... I try to keep our code internals in

Perl: utf8::decode vs. Encode::decode

久未见 提交于 2019-12-03 13:20:40
I am having some interesting results trying to discern the differences between using Encode::decode("utf8", $var) and utf8::decode($var) . I've already discovered that calling the former multiple times on a variable will eventually result in an error "Cannot decode string with wide characters at..." whereas the latter method will happily run as many times as you want, simply returning false. What I'm having trouble understanding is how the length function returns different results depending on which method you use to decode. The problem arises because I am dealing with "doubly encoded" utf8

Gmail API decoding messages in Javascript

一曲冷凌霜 提交于 2019-12-03 12:49:29
问题 I am having serious problems decoding the message body of the emails I get using the Gmail API. I want to grab the message content and put the content in a div. I am using a base64 decoder, which I know won't decode emails encoded differently, but I am not sure how to check an email to decide which decoder to use -- emails that say they are utf-8 encoded are successfully decoded by the base64 decoder, but not be a utf-8 decoder. I've been researching email decoding for several days now, and I

Meaning of “data_coding” field in SMPP

雨燕双飞 提交于 2019-12-03 10:05:28
问题 What is the meaning of "data_coding" field in the SMPP protocol? I searched for this but couldn't find any helpful resource. 回答1: In short, datacoding contains the information on how the text in an smpp SubmitSM (i.e. a typical SMS message) message is encoded. The SubmitSM packet contains a binary encoded body, and the dataCoding is how the text is stored in this body. The most important values are: 00000000 (0) - usually GSM7 (the default 7 bit encoding for messages, with a few characters

How to use base64 classes?

你。 提交于 2019-12-03 09:11:08
I want get the image from an xml file which is encoded using base64. I want to decode that data into image, but i don't know how to do that. So please give me some instructions to find that... Jhaliya There's a nice code sample at the bottom of this post. Very self-contained... http://www.cocoadev.com/index.pl?BaseSixtyFour for more read SO post 来源: https://stackoverflow.com/questions/5429680/how-to-use-base64-classes

Fastest PNG decoder for .NET

本小妞迷上赌 提交于 2019-12-03 04:24:57
Our web server needs to process many compositions of large images together before sending the results to web clients. This process is performance critical because the server can receive several thousands of requests per hour. Right now our solution loads PNG files (around 1MB each) from the HD and sends them to the video card so the composition is done on the GPU. We first tried loading our images using the PNG decoder exposed by the XNA API. We saw the performance was not too good. To understand if the problem was loading from the HD or the decoding of the PNG, we modified that by loading the